- java.lang.Object
-
- org.ojalgo.random.SampleSet
-
- All Implemented Interfaces:
Access1D<java.lang.Double>,Structure1D
public final class SampleSet extends java.lang.Object implements Access1D<java.lang.Double>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSampleSet.CombineableSet<N extends java.lang.Comparable<N>>-
Nested classes/interfaces inherited from interface org.ojalgo.structure.Access1D
Access1D.Aggregatable<N extends java.lang.Comparable<N>>, Access1D.Collectable<N extends java.lang.Comparable<N>,R extends Mutate1D>, Access1D.ElementView<N extends java.lang.Comparable<N>>, Access1D.SelectionView<N extends java.lang.Comparable<N>>, Access1D.Sliceable<N extends java.lang.Comparable<N>>, Access1D.Visitable<N extends java.lang.Comparable<N>>
-
Nested classes/interfaces inherited from interface org.ojalgo.structure.Structure1D
Structure1D.BasicMapper<T>, Structure1D.IndexMapper<T>, Structure1D.IntIndex, Structure1D.Logical<S extends Structure1D,B extends Structure1D.Logical<S,B>>, Structure1D.LongIndex, Structure1D.LoopCallback
-
-
Field Summary
Fields Modifier and Type Field Description private doublemyMaxprivate doublemyMeanprivate doublemyMinprivate doublemyQuartile1private doublemyQuartile2private doublemyQuartile3private Access1D<?>mySamplesprivate double[]mySortedCopyprivate doublemyStandardDeviationprivate doublemyVariance
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcalculateQuartiles()static doublecalculateVariance(double sumOfValues, double sumOfSquaredValues, int numberOfValues)longcount()The total number of elements in this structure.doubledoubleValue(int index)static <T> SampleSetfrom(java.lang.Iterable<T> keys)Create a sample set from counting occurrences of difference values in the iterable.java.lang.Doubleget(long index)doublegetCorrelation(SampleSet other)doublegetCovariance(SampleSet other)doublegetFirst()doublegetInterquartileRange()doublegetLargest()max(abs(value))doublegetLast()doublegetMaximum()max(value)doublegetMean()doublegetMedian()Potentially expensive as it requires copying and sorting of the samples.doublegetMidrange()The mean of the highest and lowest values.doublegetMinimum()min(value)doublegetQuartile1()https://en.wikipedia.org/wiki/QuartiledoublegetQuartile2()https://en.wikipedia.org/wiki/QuartiledoublegetQuartile3()https://en.wikipedia.org/wiki/QuartiledoublegetRange()The difference between the highest and lowest values.(package private) Access1D<?>getSamples()doublegetSmallest()min(abs(value))(package private) double[]getSortedCopy()doublegetStandardDeviation()doublegetStandardScore(int index)The standard score is the (signed) number of standard deviations an observation or datum is above the mean.doublegetSumOfSquares()Sum of squares is a concept that permeates much of inferential statistics and descriptive statistics.double[]getValues()doublegetVariance()static SampleSetmake()static SampleSetmake(RandomNumber randomNumber, int size)static java.util.stream.Collector<java.lang.Double,SampleSet.CombineableSet<java.lang.Double>,SampleSet>newCollector()static <N extends java.lang.Comparable<N>>
java.util.stream.Collector<N,SampleSet.CombineableSet<N>,SampleSet>newCollector(DenseArray.Factory<N,?> factory)static SampleSet.CombineableSet<java.lang.Double>newCombineableSet()static <N extends java.lang.Comparable<N>>
SampleSet.CombineableSet<N>newCombineableSet(DenseArray.Factory<N,?> factory)voidreset()If the underlyingAccess1Dof samples is modified you must reset the sample set before using.intsize()The total number of elements in this structure.SampleSetswap(double... samples)SampleSetswap(Access1D<?> samples)Replace the underlying samples and reset the sample set.java.lang.StringtoString()static SampleSetwrap(double... samples)static SampleSetwrap(Access1D<?> samples)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ojalgo.structure.Access1D
asCollectable1D, asKeyed1D, asList, axpy, byteValue, byteValue, dot, doubleValue, elements, floatValue, floatValue, intValue, intValue, longValue, longValue, nonzeros, select, shortValue, shortValue, supplyTo, toList, toRawCopy1D
-
-
-
-
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 setsumOfSquaredValues- The sum of all squared values, in a sample setnumberOfValues- 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.
-
make
public static SampleSet make()
-
make
public static SampleSet make(RandomNumber randomNumber, int size)
-
newCollector
public static java.util.stream.Collector<java.lang.Double,SampleSet.CombineableSet<java.lang.Double>,SampleSet> newCollector()
-
newCollector
public static <N extends java.lang.Comparable<N>> java.util.stream.Collector<N,SampleSet.CombineableSet<N>,SampleSet> newCollector(DenseArray.Factory<N,?> factory)
-
newCombineableSet
public static SampleSet.CombineableSet<java.lang.Double> newCombineableSet()
-
newCombineableSet
public static <N extends java.lang.Comparable<N>> SampleSet.CombineableSet<N> newCombineableSet(DenseArray.Factory<N,?> factory)
-
wrap
public static SampleSet wrap(double... samples)
-
count
public long count()
Description copied from interface:Structure1DThe 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:
countin interfaceStructure1D
-
doubleValue
public double doubleValue(int index)
- Specified by:
doubleValuein interfaceAccess1D<java.lang.Double>
-
get
public java.lang.Double get(long index)
-
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/QuartilePotentially expensive as it requires copying and sorting of the samples.
-
getQuartile2
public double getQuartile2()
https://en.wikipedia.org/wiki/QuartilePotentially expensive as it requires copying and sorting of the samples.
-
getQuartile3
public double getQuartile3()
https://en.wikipedia.org/wiki/QuartilePotentially 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 underlyingAccess1Dof samples is modified you must reset the sample set before using.
-
size
public int size()
Description copied from interface:Structure1DThe total number of elements in this structure.- Specified by:
sizein interfaceStructure1D
-
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:
toStringin classjava.lang.Object
-
calculateQuartiles
private void calculateQuartiles()
-
getSamples
Access1D<?> getSamples()
-
getSortedCopy
double[] getSortedCopy()
-
-