Package org.ojalgo.random
Class SampleSet
- 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 class
SampleSet.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 double
myMax
private double
myMean
private double
myMin
private double
myQuartile1
private double
myQuartile2
private double
myQuartile3
private Access1D<?>
mySamples
private double[]
mySortedCopy
private double
myStandardDeviation
private double
myVariance
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
calculateQuartiles()
static double
calculateVariance(double sumOfValues, double sumOfSquaredValues, int numberOfValues)
long
count()
The total number of elements in this structure.double
doubleValue(int index)
static <T> SampleSet
from(java.lang.Iterable<T> keys)
Create a sample set from counting occurrences of difference values in the iterable.java.lang.Double
get(long index)
double
getCorrelation(SampleSet other)
double
getCovariance(SampleSet other)
double
getFirst()
double
getInterquartileRange()
double
getLargest()
max(abs(value))double
getLast()
double
getMaximum()
max(value)double
getMean()
double
getMedian()
Potentially expensive as it requires copying and sorting of the samples.double
getMidrange()
The mean of the highest and lowest values.double
getMinimum()
min(value)double
getQuartile1()
https://en.wikipedia.org/wiki/Quartiledouble
getQuartile2()
https://en.wikipedia.org/wiki/Quartiledouble
getQuartile3()
https://en.wikipedia.org/wiki/Quartiledouble
getRange()
The difference between the highest and lowest values.(package private) Access1D<?>
getSamples()
double
getSmallest()
min(abs(value))(package private) double[]
getSortedCopy()
double
getStandardDeviation()
double
getStandardScore(int index)
The standard score is the (signed) number of standard deviations an observation or datum is above the mean.double
getSumOfSquares()
Sum of squares is a concept that permeates much of inferential statistics and descriptive statistics.double[]
getValues()
double
getVariance()
static SampleSet
make()
static SampleSet
make(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)
void
reset()
If the underlyingAccess1D
of samples is modified you must reset the sample set before using.int
size()
The total number of elements in this structure.SampleSet
swap(double... samples)
SampleSet
swap(Access1D<?> samples)
Replace the underlying samples and reset the sample set.java.lang.String
toString()
static SampleSet
wrap(double... samples)
static SampleSet
wrap(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, axpy, byteValue, byteValue, dot, doubleValue, elements, floatValue, floatValue, intValue, intValue, longValue, longValue, nonzeros, select, shortValue, shortValue, supplyTo, 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: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 interfaceStructure1D
-
doubleValue
public double doubleValue(int index)
- Specified by:
doubleValue
in 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 underlyingAccess1D
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 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:
toString
in classjava.lang.Object
-
calculateQuartiles
private void calculateQuartiles()
-
getSamples
Access1D<?> getSamples()
-
getSortedCopy
double[] getSortedCopy()
-
-