com.github.TKnudsen.ComplexDataObject.data.uncertainty.range.ValueUncertaintyRange 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.range;
import java.util.Collection;
import com.github.TKnudsen.ComplexDataObject.data.uncertainty.Double.ValueUncertainty;
import com.github.TKnudsen.ComplexDataObject.model.tools.StatisticsSupport;
/**
*
* Data model of an uncertainty that is associated with a single value and that
* covers a range. This means that this uncertainty describes how far a value
* may deviate from the actual value: For a given value v
and an
* (absolute) value uncertainty range (lower,upper)
, the actual
* value will be in [v+lower,v+upper]
.
*
*
*
* Copyright: (c) 2015-2018 Juergen Bernard,
* https://github.com/TKnudsen/ComplexDataObject
*
*
* @author Juergen Bernard
* @version 1.03
*/
public class ValueUncertaintyRange extends ValueUncertainty implements IValueUncertaintyRange {
private double upperBound;
private double lowerBound;
public ValueUncertaintyRange() {
super();
}
public ValueUncertaintyRange(double amount) {
super(amount);
}
public ValueUncertaintyRange(Collection extends Double> values) {
super();
initialize(values);
}
private void initialize(Collection extends Double> values) {
StatisticsSupport statisticsSupport = new StatisticsSupport(values);
this.setAmount(statisticsSupport.getMedian());
this.lowerBound = statisticsSupport.getMin();
this.upperBound = statisticsSupport.getMax();
}
@Override
public String toString() {
return "ValueUncertaintyRange. Amount: " + getAmount() + ", bounds: [" + getLowerBound() + ", "
+ getUpperBound() + "]";
}
@Override
public double getUpperBound() {
return upperBound;
}
public void setUpperBound(double upperBound) {
this.upperBound = upperBound;
}
@Override
public double getLowerBound() {
return lowerBound;
}
public void setLowerBound(double lowerBound) {
this.lowerBound = lowerBound;
}
}