    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         *
    028         * @param dataset
    029         */
    030        public void initialize(Dataset dataset);
    031
    032        /**
    033         * Call to indicate dataset has been modified so statistics are not up-to-date
    034         */
    035        public void setDirty();
    036
    037        /**
    038         * @return true if dataset has been modified
    039         */
    040        public boolean isDirty();
    041
    042        /**
    043         * @param dataset dataset whose statistics is stored by this metadata
    044         * @return true if dataset has been modified
    045         * @since 2.2
    046         */
    047        public boolean isDirty(Dataset dataset);
    048
    049        /**
    050         * @param hash the hash to set
    051         */
    052        public void setHash(int hash);
    053
    054        /**
    055         * @param shape
    056         * @return the hash
    057         */
    058        public int getHash(int[] shape);
    059
    060        /**
    061         * @param ignoreInvalids - Can be null, one boolean, or two booleans. By default, both are false. If
    062         * the first boolean is true, will ignore NaNs and ignore infinities. Use the second boolean to
    063         * ignore infinities separately.
    064         * @return the maximum
    065         */
    066        public T getMaximum(boolean... ignoreInvalids);
    067
    068        /**
    069         * @param maximum the maximum to set
    070         * @param minimum the minimum to set
    071         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    072         */
    073        @Deprecated
    074        public void setMaximumMinimum(T maximum, T minimum, boolean... ignoreInvalids);
    075
    076        /**
    077         * @param maximum the maximum to set
    078         * @param minimum the minimum to set
    079         * @param sum the sum to set
    080         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    081         * @since 2.1
    082         */
    083        public void setMaximumMinimumSum(T maximum, T minimum, T sum, boolean... ignoreInvalids);
    084
    085        /**
    086         * @param maximumPositions the maximum positions to set
    087         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    088         */
    089        public void setMaximumPositions(List<int[]> maximumPositions, boolean... ignoreInvalids);
    090
    091        /**
    092         * @param minimumPositions the minimum positions to set
    093         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    094         */
    095        public void setMinimumPositions(List<int[]> minimumPositions, boolean... ignoreInvalids);
    096
    097        /**
    098         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    099         * @return the maximum positions
    100         */
    101        public List<int[]> getMaximumPositions(boolean... ignoreInvalids);
    102
    103        /**
    104         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    105         * @return the minimum
    106         */
    107        public T getMinimum(boolean... ignoreInvalids);
    108
    109        /**
    110         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    111         * @return the minimum positions
    112         */
    113        public List<int[]> getMinimumPositions(boolean... ignoreInvalids);
    114
    115        /**
    116         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    117         * @return the number of samples
    118         */
    119        public long getCount(boolean... ignoreInvalids);
    120
    121        /**
    122         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    123         * @return the mean of samples
    124         */
    125        public T getMean(boolean... ignoreInvalids);
    126
    127        /**
    128         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    129         * @return the sum of samples
    130         */
    131        public T getSum(boolean... ignoreInvalids);
    132
    133        /**
    134         * @param isWholePopulation
    135         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    136         * @return the variance of samples
    137         */
    138        public double getVariance(boolean isWholePopulation, boolean... ignoreInvalids);
    139
    140        /**
    141         * @param axis
    142         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    143         * @return the argument at which the maximum first occurs
    144         */
    145        public Dataset getArgMaximum(int axis, boolean... ignoreInvalids);
    146
    147        /**
    148         * @param axis
    149         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    150         * @return the argument at which the minimum first occurs
    151         */
    152        public Dataset getArgMinimum(int axis, boolean... ignoreInvalids);
    153
    154        /**
    155         * @param axis
    156         * @param ignoreInvalids - Can be null, one boolean, or two booleans. By default, both are false. If
    157         * the first boolean is true, will ignore NaNs and ignore infinities. Use the second boolean to
    158         * ignore infinities separately.
    159         * @return the maximum
    160         */
    161        public Dataset getMaximum(int axis, boolean... ignoreInvalids);
    162
    163        /**
    164         * @param axis
    165         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    166         * @return the minimum
    167         */
    168        public Dataset getMinimum(int axis, boolean... ignoreInvalids);
    169
    170        /**
    171         * @param axis
    172         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    173         * @return the number of samples
    174         */
    175        public Dataset getCount(int axis, boolean... ignoreInvalids);
    176
    177        /**
    178         * @param axis
    179         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    180         * @return the mean of samples
    181         */
    182        public Dataset getMean(int axis, boolean... ignoreInvalids);
    183
    184        /**
    185         * @param axis
    186         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    187         * @return the sum of samples
    188         */
    189        public Dataset getSum(int axis, boolean... ignoreInvalids);
    190
    191        /**
    192         * @param axis
    193         * @param isWholePopulation
    194         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    195         * @return the variance of samples
    196         */
    197        public Dataset getVariance(int axis, boolean isWholePopulation, boolean... ignoreInvalids);
    198
    199        /**
    200         * @param axes
    201         * @param ignoreInvalids - Can be null, one boolean, or two booleans. By default, both are false. If
    202         * the first boolean is true, will ignore NaNs and ignore infinities. Use the second boolean to
    203         * ignore infinities separately.
    204         * @return the maximum
    205         * @since 2.2
    206         */
    207        public Dataset getMaximum(int[] axes, boolean... ignoreInvalids);
    208
    209        /**
    210         * @param axes
    211         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    212         * @return the minimum
    213         * @since 2.2
    214         */
    215        public Dataset getMinimum(int[] axes, boolean... ignoreInvalids);
    216
    217        /**
    218         * @param axes
    219         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    220         * @return the number of samples
    221         * @since 2.2
    222         */
    223        public Dataset getCount(int[] axes, boolean... ignoreInvalids);
    224
    225        /**
    226         * @param axes
    227         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    228         * @return the mean of samples
    229         * @since 2.2
    230         */
    231        public Dataset getMean(int[] axes, boolean... ignoreInvalids);
    232
    233        /**
    234         * @param axes
    235         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    236         * @return the sum of samples
    237         * @since 2.2
    238         */
    239        public Dataset getSum(int[] axes, boolean... ignoreInvalids);
    240
    241        /**
    242         * @param axes
    243         * @param isWholePopulation
    244         * @param ignoreInvalids see {@link #getMaximum(boolean...)} for explanation
    245         * @return the variance of samples
    246         * @since 2.2
    247         */
    248        public Dataset getVariance(int[] axes, boolean isWholePopulation, boolean... ignoreInvalids);
    249}