Skip to content

Add convenience method for initialization #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -132,6 +132,26 @@ public SummaryStatistics(SummaryStatistics original) throws NullArgumentExceptio
copy(original, this);
}

/**
* Construct a SummaryStatistics instance filling it with the given initialDoubleArray
* @param initialDoubleArray values for filling the array
*/
public SummaryStatistics(double[] initialDoubleArray) {
for (double initialValue : initialDoubleArray) {
addValue(initialValue);
}
}

/**
* Construct a SummaryStatistics instance filling it with the given initialDoubleArray
* @param initialDoubleArray values for filling the array
*/
public SummaryStatistics(Double[] initialDoubleArray) {
for (Double initialValue : initialDoubleArray) {
addValue(initialValue);
}
}

/**
* Return a {@link StatisticalSummaryValues} instance reporting current
* statistics.
Original file line number Diff line number Diff line change
@@ -315,6 +315,9 @@ public void testQuadraticMean() {
expected = Math.sqrt(expected);

Assert.assertEquals(expected, stats.getQuadraticMean(), Math.ulp(expected));

SummaryStatistics convenienceMethodStatistics = new SummaryStatistics(values);
Assert.assertEquals(expected, convenienceMethodStatistics.getQuadraticMean(), Math.ulp(expected));
}

/**