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