Refactors
- getNode method to handle invalid node index and improve error handling - update parameter description in SimulationMultiple constructor - enhance calcError method in StatisticsSummary for better clarity and functionality.
This commit is contained in:
@@ -45,21 +45,6 @@ public class StatisticsSummary {
|
||||
this.distr = new TDistribution(null, values.length - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the error at the selected alpha level.
|
||||
* This method computes the error for the average and standard deviation values,
|
||||
* considering the sample size and the confidence level (alpha).
|
||||
* The result is adjusted using a t-distribution to account for the variability
|
||||
* in smaller sample sizes.
|
||||
*
|
||||
* @param alpha the alpha value
|
||||
* @return the error of the values
|
||||
*/
|
||||
public double calcError(double alpha) {
|
||||
var percentile = this.distr.inverseCumulativeProbability(alpha);
|
||||
return percentile * (this.stdDev / Math.sqrt(this.values.length));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the frequency of the values in the array.
|
||||
*
|
||||
@@ -90,6 +75,38 @@ public class StatisticsSummary {
|
||||
return this.values[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the error at the selected alpha level.
|
||||
* This method computes the error for the average and standard deviation values,
|
||||
* considering the sample size and the confidence level (alpha).
|
||||
* The result is adjusted using a t-distribution to account for the variability
|
||||
* in smaller sample sizes.
|
||||
*
|
||||
* @param alpha the alpha value
|
||||
* @return the error of the values
|
||||
*/
|
||||
public double calcError(double alpha) {
|
||||
return StatisticsSummary.calcError(this.distr, this.stdDev, alpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the error at the selected alpha level.
|
||||
* This method computes the error for the average and standard deviation values,
|
||||
* considering the sample size and the confidence level (alpha).
|
||||
* The result is adjusted using a t-distribution to account for the variability
|
||||
* in smaller sample sizes.
|
||||
*
|
||||
* @param distribution the t-distribution to use
|
||||
* @param stdDev the standard deviation of the values
|
||||
* @param alpha the alpha value
|
||||
* @return the error of the values
|
||||
*/
|
||||
public static double calcError(TDistribution distribution, double stdDev, double alpha) {
|
||||
var percentile = distribution.inverseCumulativeProbability(alpha);
|
||||
var n = distribution.getDegreesOfFreedom() + 1;
|
||||
return percentile * (stdDev / Math.sqrt(n));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a summary of the statistics.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user