Class SampleSet

  • All Implemented Interfaces:
    Access1D<java.lang.Double>, Structure1D

    public final class SampleSet
    extends java.lang.Object
    implements Access1D<java.lang.Double>
    • Field Detail

      • myMax

        private transient double myMax
      • myMean

        private transient double myMean
      • myMin

        private transient double myMin
      • myQuartile1

        private transient double myQuartile1
      • myQuartile2

        private transient double myQuartile2
      • myQuartile3

        private transient double myQuartile3
      • mySamples

        private Access1D<?> mySamples
      • mySortedCopy

        private transient double[] mySortedCopy
      • myStandardDeviation

        private transient double myStandardDeviation
      • myVariance

        private transient double myVariance
    • Constructor Detail

      • SampleSet

        SampleSet​(Access1D<?> samples)
    • Method Detail

      • calculateVariance

        public static double calculateVariance​(double sumOfValues,
                                               double sumOfSquaredValues,
                                               int numberOfValues)
        Parameters:
        sumOfValues - The sum of all values in a sample set
        sumOfSquaredValues - The sum of all squared values, in a sample set
        numberOfValues - The number of values in the sample set
        Returns:
        The sample set's variance
      • from

        public static <T> SampleSet from​(java.lang.Iterable<T> keys)
        Create a sample set from counting occurrences of difference values in the iterable.
      • wrap

        public static SampleSet wrap​(double... samples)
      • count

        public long count()
        Description copied from interface: Structure1D
        The total number of elements in this structure.

        You only need to implement this method if the structure can contain more than Integer.MAX_VALUE elements.

        Specified by:
        count in interface Structure1D
      • doubleValue

        public double doubleValue​(int index)
        Specified by:
        doubleValue in interface Access1D<java.lang.Double>
      • get

        public java.lang.Double get​(long index)
        Specified by:
        get in interface Access1D<java.lang.Double>
      • getCorrelation

        public double getCorrelation​(SampleSet other)
      • getCovariance

        public double getCovariance​(SampleSet other)
      • getFirst

        public double getFirst()
      • getInterquartileRange

        public double getInterquartileRange()
      • getLargest

        public double getLargest()
        max(abs(value))
      • getLast

        public double getLast()
      • getMaximum

        public double getMaximum()
        max(value)
      • getMean

        public double getMean()
      • getMedian

        public double getMedian()
        Potentially expensive as it requires copying and sorting of the samples.
      • getMidrange

        public double getMidrange()
        The mean of the highest and lowest values. (Max + Min) / 2
      • getMinimum

        public double getMinimum()
        min(value)
      • getQuartile1

        public double getQuartile1()
        https://en.wikipedia.org/wiki/Quartile

        Potentially expensive as it requires copying and sorting of the samples.

      • getQuartile2

        public double getQuartile2()
        https://en.wikipedia.org/wiki/Quartile

        Potentially expensive as it requires copying and sorting of the samples.

      • getQuartile3

        public double getQuartile3()
        https://en.wikipedia.org/wiki/Quartile

        Potentially expensive as it requires copying and sorting of the samples.

      • getRange

        public double getRange()
        The difference between the highest and lowest values. Max - Min
      • getSmallest

        public double getSmallest()
        min(abs(value))
      • getStandardDeviation

        public double getStandardDeviation()
      • getStandardScore

        public double getStandardScore​(int index)
        The standard score is the (signed) number of standard deviations an observation or datum is above the mean. Thus, a positive standard score indicates a datum above the mean, while a negative standard score indicates a datum below the mean. It is a dimensionless quantity obtained by subtracting the population mean from an individual raw score and then dividing the difference by the population standard deviation.
        See Also:
        WikipediA
      • getSumOfSquares

        public double getSumOfSquares()
        Sum of squares is a concept that permeates much of inferential statistics and descriptive statistics. More properly, it is "the sum of the squared deviations". Mathematically, it is an unscaled, or unadjusted measure of dispersion (also called variability). When scaled for the number of degrees of freedom, it estimates the variance, or spread of the observations about their mean value.
        See Also:
        WikipediA
      • getValues

        public double[] getValues()
        Returns:
        A copy of the internal data (the samples).
      • getVariance

        public double getVariance()
      • reset

        public void reset()
        If the underlying Access1D of samples is modified you must reset the sample set before using.
      • size

        public int size()
        Description copied from interface: Structure1D
        The total number of elements in this structure.
        Specified by:
        size in interface Structure1D
      • swap

        public SampleSet swap​(Access1D<?> samples)
        Replace the underlying samples and reset the sample set.
      • swap

        public SampleSet swap​(double... samples)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • calculateQuartiles

        private void calculateQuartiles()
      • getSortedCopy

        double[] getSortedCopy()