com.github.TKnudsen.ComplexDataObject.data.uncertainty.distribution.ValueUncertaintyDistribution Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of complex-data-object Show documentation
Show all versions of complex-data-object Show documentation
A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.
The newest version!
package com.github.TKnudsen.ComplexDataObject.data.uncertainty.distribution;
import java.util.Collection;
import com.github.TKnudsen.ComplexDataObject.data.uncertainty.range.ValueUncertaintyRange;
import com.github.TKnudsen.ComplexDataObject.model.tools.StatisticsSupport;
/**
*
* Data model for uncertainties of numerical values characterized by a
* statistical distribution.
*
*
*
* Copyright: (c) 2015-2018 Juergen Bernard,
* https://github.com/TKnudsen/ComplexDataObject
*
*
* @author Juergen Bernard
* @version 1.08
*/
public class ValueUncertaintyDistribution extends ValueUncertaintyRange implements IValueUncertaintyDistribution {
private double upperQartile;
private double median;
private double lowerQuartile;
private double variance;
private double standardDeviation;
int size;
@SuppressWarnings("unused")
private ValueUncertaintyDistribution() {
super();
}
public ValueUncertaintyDistribution(Collection extends Double> values) {
super();
initialize(values);
}
private void initialize(Collection extends Double> values) {
StatisticsSupport statisticsSupport = new StatisticsSupport(values);
this.setAmount(statisticsSupport.getMedian());
this.setLowerBound(statisticsSupport.getMin());
this.setUpperBound(statisticsSupport.getMax());
this.upperQartile = statisticsSupport.getPercentile(75);
this.median = statisticsSupport.getMedian();
this.lowerQuartile = statisticsSupport.getPercentile(25);
this.variance = statisticsSupport.getVariance();
this.standardDeviation = statisticsSupport.getStandardDeviation();
this.size = values.size();
}
@Override
public String toString() {
return "ValueUncertaintyDistribution. Amount: " + getAmount() + ", bounds: [" + getLowerBound() + ", "
+ getUpperBound() + "]";
}
@Override
public double getUpperQartile() {
return upperQartile;
}
@Override
public double getMedian() {
return median;
}
@Override
public double getLowerQuartile() {
return lowerQuartile;
}
@Override
public double getVariance() {
return variance;
}
@Override
public double getStandardDeviation() {
return standardDeviation;
}
@Override
public int size() {
return size;
}
}