    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 hash the hash to set
    044         */
    045        public void setHash(int hash);
    046
    047        /**
    048         * @param shape
    049         * @return the hash
    050         */
    051        public int getHash(int[] shape);
    052
    053        /**
    054         * @param ignoreInvalids - Can be null, one boolean, or two booleans. By default, both are false. If
    055         * the first boolean is true, will ignore NaNs and ignore infinities. Use the second boolean to
    056         * ignore infinities separately.
    057         * @return the maximum
    058         */
    059        public T getMaximum(boolean... ignoreInvalids);
    060
    061        /**
    062         * @param maximum the maximum to set
    063         * @param minimum the minimum to set
    064         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    065         */
    066        @Deprecated
    067        public void setMaximumMinimum(T maximum, T minimum, boolean... ignoreInvalids);
    068
    069        /**
    070         * @param maximum the maximum to set
    071         * @param minimum the minimum to set
    072         * @param sum the sum to set
    073         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    074         * @since 2.1
    075         */
    076        public void setMaximumMinimumSum(T maximum, T minimum, T sum, boolean... ignoreInvalids);
    077
    078        /**
    079         * @param maximumPositions the maximum positions to set
    080         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    081         */
    082        public void setMaximumPositions(List<int[]> maximumPositions, boolean... ignoreInvalids);
    083
    084        /**
    085         * @param minimumPositions the minimum positions to set
    086         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    087         */
    088        public void setMinimumPositions(List<int[]> minimumPositions, boolean... ignoreInvalids);
    089
    090        /**
    091         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    092         * @return the maximum positions
    093         */
    094        public List<int[]> getMaximumPositions(boolean... ignoreInvalids);
    095
    096        /**
    097         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    098         * @return the minimum
    099         */
    100        public T getMinimum(boolean... ignoreInvalids);
    101
    102        /**
    103         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    104         * @return the minimum positions
    105         */
    106        public List<int[]> getMinimumPositions(boolean... ignoreInvalids);
    107
    108        /**
    109         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    110         * @return the number of samples
    111         */
    112        public long getCount(boolean... ignoreInvalids);
    113
    114        /**
    115         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    116         * @return the mean of samples
    117         */
    118        public T getMean(boolean... ignoreInvalids);
    119
    120        /**
    121         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    122         * @return the sum of samples
    123         */
    124        public T getSum(boolean... ignoreInvalids);
    125
    126        /**
    127         * @param isWholePopulation
    128         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    129         * @return the variance of samples
    130         */
    131        public double getVariance(boolean isWholePopulation, boolean... ignoreInvalids);
    132
    133        /**
    134         * @param ignoreInvalids - Can be null, one boolean, or two booleans. By default, both are false. If
    135         * the first boolean is true, will ignore NaNs and ignore infinities. Use the second boolean to
    136         * ignore infinities separately.
    137         * @return the maximum
    138         */
    139        public Dataset getMaximum(int axis, boolean... ignoreInvalids);
    140
    141        /**
    142         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    143         * @return the minimum
    144         */
    145        public Dataset getMinimum(int axis, boolean... ignoreInvalids);
    146
    147        /**
    148         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    149         * @return the argument at which the maximum first occurs
    150         */
    151        public Dataset getArgMaximum(int axis, boolean... ignoreInvalids);
    152
    153        /**
    154         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    155         * @return the argument at which the minimum first occurs
    156         */
    157        public Dataset getArgMinimum(int axis, boolean... ignoreInvalids);
    158
    159        // TODO LongDataset
    160        /**
    161         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    162         * @return the number of samples
    163         */
    164        public Dataset getCount(int axis, boolean... ignoreInvalids);
    165
    166        /**
    167         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    168         * @return the mean of samples
    169         */
    170        public Dataset getMean(int axis, boolean... ignoreInvalids);
    171
    172        /**
    173         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    174         * @return the sum of samples
    175         */
    176        public Dataset getSum(int axis, boolean... ignoreInvalids);
    177
    178        /**
    179         * @param isWholePopulation
    180         * @param ignoreInvalids @see {@link #getMaximum(boolean...)} for explanation
    181         * @return the variance of samples
    182         */
    183        public Dataset getVariance(int axis, boolean isWholePopulation, boolean... ignoreInvalids);
    184}