    001/*-
    002 *******************************************************************************
    003 * Copyright (c) 2017 Diamond Light Source Ltd.
    004 * All rights reserved. This program and the accompanying materials
    005 * are made available under the terms of the Eclipse Public License v1.0
    006 * which accompanies this distribution, and is available at
    007 * http://www.eclipse.org/legal/epl-v10.html
    008 *
    009 * Contributors:
    010 *    Peter Chang - initial API and implementation and/or initial documentation
    011 *******************************************************************************/
    012
    013package org.eclipse.january.metadata;
    014
    015import java.util.List;
    016
    017import org.eclipse.january.dataset.Dataset;
    018
    019/**
    020 * Store standard statistics
    021 * @param <T> is either a Number or a double array
    022 * @since 2.0
    023 */
    024public interface StatisticsMetadata<T> extends MetadataType {
    025
    026        /**
    027         * @param dataset to use
    028         */
    029        public void initialize(Dataset dataset);
    030
    031        /**
    032         * Call to indicate dataset has been modified so statistics are not up-to-date
    033         */
    034        public void setDirty();
    035
    036        /**
    037         * @return true if dataset has been modified
    038         */
    039        public boolean isDirty();
    040
    041        /**
    042         * @param dataset dataset whose statistics is stored by this metadata
    043         * @return true if dataset has been modified
    044         * @since 2.2
    045         */
    046        public boolean isDirty(Dataset dataset);
    047
    048        /**
    049         * @param hash the hash to set
    050         */
    051        public void setHash(int hash);
    052
    053        /**
    054         * @param shape to hash with data
    055         * @return the hash
    056         */
    057        public int getHash(int[] shape);
    058
    059        /**
    060         * @param ignoreInvalids - Can be null, one boolean, or two booleans. By default, both are false. If
    061         * the first boolean is true, will ignore NaNs and ignore infinities. Use the second boolean to
    062         * ignore infinities separately.
    063         * @return the maximum
    064         */
    065        public T getMaximum(boolean... ignoreInvalids);
    066
    067        /**
    068         * @param maximum the maximum to set
    069         * @param minimum the minimum to set
    070         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    071         */
    072        @Deprecated
    073        public void setMaximumMinimum(T maximum, T minimum, boolean... ignoreInvalids);
    074
    075        /**
    076         * @param maximum the maximum to set
    077         * @param minimum the minimum to set
    078         * @param sum the sum to set
    079         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    080         * @since 2.1
    081         */
    082        public void setMaximumMinimumSum(T maximum, T minimum, T sum, boolean... ignoreInvalids);
    083
    084        /**
    085         * @param maximumPositions the maximum positions to set
    086         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    087         */
    088        public void setMaximumPositions(List<int[]> maximumPositions, boolean... ignoreInvalids);
    089
    090        /**
    091         * @param minimumPositions the minimum positions to set
    092         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    093         */
    094        public void setMinimumPositions(List<int[]> minimumPositions, boolean... ignoreInvalids);
    095
    096        /**
    097         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    098         * @return the maximum positions
    099         */
    100        public List<int[]> getMaximumPositions(boolean... ignoreInvalids);
    101
    102        /**
    103         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    104         * @return the minimum
    105         */
    106        public T getMinimum(boolean... ignoreInvalids);
    107
    108        /**
    109         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    110         * @return the minimum positions
    111         */
    112        public List<int[]> getMinimumPositions(boolean... ignoreInvalids);
    113
    114        /**
    115         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    116         * @return the number of samples
    117         */
    118        public long getCount(boolean... ignoreInvalids);
    119
    120        /**
    121         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    122         * @return the mean of samples
    123         */
    124        public T getMean(boolean... ignoreInvalids);
    125
    126        /**
    127         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    128         * @return the sum of samples
    129         */
    130        public T getSum(boolean... ignoreInvalids);
    131
    132        /**
    133         * @param isWholePopulation if false, consider as sample of population
    134         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    135         * @return the variance of samples
    136         */
    137        public double getVariance(boolean isWholePopulation, boolean... ignoreInvalids);
    138
    139        /**
    140         * @param axis to reduce along
    141         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    142         * @return the argument at which the maximum first occurs
    143         */
    144        public Dataset getArgMaximum(int axis, boolean... ignoreInvalids);
    145
    146        /**
    147         * @param axis to reduce along
    148         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    149         * @return the argument at which the minimum first occurs
    150         */
    151        public Dataset getArgMinimum(int axis, boolean... ignoreInvalids);
    152
    153        /**
    154         * @param axis to reduce along
    155         * @param ignoreInvalids - Can be null, one boolean, or two booleans. By default, both are false. If
    156         * the first boolean is true, will ignore NaNs and ignore infinities. Use the second boolean to
    157         * ignore infinities separately.
    158         * @return the maximum
    159         */
    160        public Dataset getMaximum(int axis, boolean... ignoreInvalids);
    161
    162        /**
    163         * @param axis to reduce along
    164         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    165         * @return the minimum
    166         */
    167        public Dataset getMinimum(int axis, boolean... ignoreInvalids);
    168
    169        /**
    170         * @param axis to reduce along
    171         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    172         * @return the number of samples
    173         */
    174        public Dataset getCount(int axis, boolean... ignoreInvalids);
    175
    176        /**
    177         * @param axis to reduce along
    178         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    179         * @return the mean of samples
    180         */
    181        public Dataset getMean(int axis, boolean... ignoreInvalids);
    182
    183        /**
    184         * @param axis to reduce along
    185         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    186         * @return the sum of samples
    187         */
    188        public Dataset getSum(int axis, boolean... ignoreInvalids);
    189
    190        /**
    191         * @param axis to reduce along
    192         * @param isWholePopulation if false, consider as sample of population
    193         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    194         * @return the variance of samples
    195         */
    196        public Dataset getVariance(int axis, boolean isWholePopulation, boolean... ignoreInvalids);
    197
    198        /**
    199         * @param axes to reduce along
    200         * @param ignoreInvalids - Can be null, one boolean, or two booleans. By default, both are false. If
    201         * the first boolean is true, will ignore NaNs and ignore infinities. Use the second boolean to
    202         * ignore infinities separately.
    203         * @return the maximum
    204         * @since 2.2
    205         */
    206        public Dataset getMaximum(int[] axes, boolean... ignoreInvalids);
    207
    208        /**
    209         * @param axes to reduce over
    210         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    211         * @return the minimum
    212         * @since 2.2
    213         */
    214        public Dataset getMinimum(int[] axes, boolean... ignoreInvalids);
    215
    216        /**
    217         * @param axes to reduce over
    218         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    219         * @return the number of samples
    220         * @since 2.2
    221         */
    222        public Dataset getCount(int[] axes, boolean... ignoreInvalids);
    223
    224        /**
    225         * @param axes to reduce over
    226         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    227         * @return the mean of samples
    228         * @since 2.2
    229         */
    230        public Dataset getMean(int[] axes, boolean... ignoreInvalids);
    231
    232        /**
    233         * @param axes to reduce over
    234         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    235         * @return the sum of samples
    236         * @since 2.2
    237         */
    238        public Dataset getSum(int[] axes, boolean... ignoreInvalids);
    239
    240        /**
    241         * @param axes to reduce along
    242         * @param isWholePopulation if false, consider as sample of population
    243         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    244         * @return the variance of samples
    245         * @since 2.2
    246         */
    247        public Dataset getVariance(int[] axes, boolean isWholePopulation, boolean... ignoreInvalids);
    248}