and are
parameters of the distribution and is the error tolerance of the test.
The function computes the probabilities using R and compares the values that
R produces with those in the vector.
verifyDensity <- function(points, expected, n, p, tol) {
rDensityValues <- rep(0, length(points))
i <- 0
for (point in points) {
i <- i + 1
rDensityValues[i] <- dbinom(point, n, p, log = FALSE)
}
output <- c("Density test n = ", n, ", p = ", p)
if (assertEquals(expected,rDensityValues,tol,"Density Values")) {
displayPadded(output, SUCCEEDED, WIDTH)
} else {
displayPadded(output, FAILED, WIDTH)
}
}
The displayPadded function just displays its first and second arguments with
enough dots in between to make the whole string WIDTH characters long. It is
defined in testFunctions.
Then call this function with different parameters corresponding to the different
Junit test cases:
size <- 10.0
probability <- 0.70
densityPoints <- c(-1,0,1,2,3,4,5,6,7,8,9,10,11)
densityValues <- c(0, 0.0000, 0.0001, 0.0014, 0.0090, 0.0368, 0.1029,
0.2001, 0.2668, 0.2335, 0.1211, 0.0282, 0)
...
verifyDensity(densityPoints, densityValues, size, probability, tol)
If the values computed by R match the target values in densityValues, this will
produce one line of output to the console:
Density test n = 10, p = 0.7...........................................SUCCEEDED
If you modify the value of tol set at the top of binomialTestCases to make the
test more sensitive than the number of digits specified in the densityValues
vector, it will fail, producing the following output, showing the failure and
the expected and observed values:
FAILURE: Density Values
EXPECTED: 0 0 1e-04 0.0014 0.009 0.0368 0.1029 0.2001 0.2668 0.2335 0.1211 /
0.0282 0
OBSERVED: 0 5.9049e-06 0.000137781 0.0014467005 0.009001692 0.036756909 /
0.1029193452 0.200120949 0.266827932 0.2334744405 0.121060821 0.0282475249 0
Density test n = 10, p = 0.7..............................................FAILED
commons-math-2.2-src/src/test/R/poissonTestCases 100644 1750 1750 10212 11532241241 20507 0 ustar luc luc 0 0 # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#------------------------------------------------------------------------------
# R source file to validate Poisson distribution tests in
# org.apache.commons.math.distribution.PoissonDistributionTest
#
# To run the test, install R, put this file and testFunctions
# into the same directory, launch R from this directory and then enter
# source("")
#
# R functions used
# dpois(x, lambda, log = FALSE) <-- density
# ppois(q, lambda, lower.tail = TRUE, log.p = FALSE) <-- distribution
# pnorm(q, mean=0, sd=1, lower.tail = TRUE, log.p = FALSE) <-- normal dist.
#------------------------------------------------------------------------------
tol <- 1E-10
#------------------------------------------------------------------------------
# Function definitions
source("testFunctions") # utility test functions
# function to verify density computations
verifyDensity <- function(points, expected, lambda, tol) {
rDensityValues <- rep(0, length(points))
i <- 0
for (point in points) {
i <- i + 1
rDensityValues[i] <- dpois(point, lambda, log = FALSE)
}
output <- c("Density test lambda = ", lambda)
if (assertEquals(expected, rDensityValues, tol, "Density Values")) {
displayPadded(output, SUCCEEDED, WIDTH)
} else {
displayPadded(output, FAILED, WIDTH)
}
}
# function to verify distribution computations
verifyDistribution <- function(points, expected, lambda, tol) {
rDistValues <- rep(0, length(points))
i <- 0
for (point in points) {
i <- i + 1
rDistValues[i] <- ppois(point, lambda, log = FALSE)
}
output <- c("Distribution test lambda = ", lambda)
if (assertEquals(expected, rDistValues, tol, "Distribution Values")) {
displayPadded(output, SUCCEEDED, WIDTH)
} else {
displayPadded(output, FAILED, WIDTH)
}
}
# function to verify normal approximation
verifyNormalApproximation <- function(expected, lambda, lower, upper, tol) {
rValue <- pnorm(upper, mean=lambda, sd=sqrt(lambda), lower.tail = TRUE,
log.p = FALSE) -
pnorm(lower, mean=lambda, sd=sqrt(lambda), lower.tail = TRUE,
log.p = FALSE)
output <- c("Normal approx. test lambda = ", lambda, " upper = ",
upper, " lower = ", lower)
if (assertEquals(expected, rValue, tol, "Distribution Values")) {
displayPadded(output, SUCCEEDED, WIDTH)
} else {
displayPadded(output, FAILED, WIDTH)
}
}
cat("Poisson distribution test cases\n")
# stock tests
lambda <- 4.0
densityPoints <- c(-1,0,1,2,3,4,5,10,20)
densityValues <- c(0, 0.0183156388887, 0.073262555555, 0.14652511111,
0.195366814813, 0.195366814813, 0.156293451851,
0.00529247667642, 8.27746364655e-09)
verifyDensity(densityPoints, densityValues, lambda, tol)
distributionPoints <- c(-1, 0, 1, 2, 3, 4, 5, 10, 20)
distributionValues <- c(0, 0.0183156388887, 0.0915781944437, 0.238103305554,
0.433470120367, 0.62883693518, 0.78513038703,
0.99716023388, 0.999999998077)
verifyDistribution(distributionPoints, distributionValues, lambda, tol)
# normal approximation tests
lambda <- 100
verifyNormalApproximation(0.706281887248, lambda, 89.5, 110.5, tol)
lambda <- 10000
verifyNormalApproximation(0.820070051552, lambda, 9899.5, 10200.5, tol)
displayDashes(WIDTH)
commons-math-2.2-src/src/test/R/TTestCases 100644 1750 1750 10413 11532241241 17223 0 ustar luc luc 0 0 # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#------------------------------------------------------------------------------
# R source file to validate TTest tests in
# org.apache.commons.math.inference.TTestImpl
#
# To run the test, install R, put this file and testFunctions
# into the same directory, launch R from this directory and then enter
# source("")
#
# R functions used
# t.test(x, y = NULL, alternative = c("two.sided", "less", "greater"),
# mu = 0, paired = FALSE, var.equal = FALSE, ... )
# Arguments
# x a numeric vector of data values.
# y an optional numeric vector data values.
# alternative a character string specifying the alternative hypothesis,
# must be one of "two.sided" (default), "greater" or "less". You can specify
# just the initial letter.
# mu a number indicating the true value of the mean (or difference in means
# if you are performing a two sample test).
# paired a logical indicating whether you want a paired t-test.
# var.equal a logical variable indicating whether to treat the two
# variances as being equal.
# If TRUE then the pooled variance is used to estimate the variance,
# otherwise the Welch (or Satterthwaite) approximation to the degrees
# of freedom is used.
#------------------------------------------------------------------------------
tol <- 1E-10 # error tolerance for tests
#------------------------------------------------------------------------------
# Function definitions
#------------------------------------------------------------------------------
source("testFunctions") # utility test functions
#------------------------------------------------------------------------------
# Verification function
#
verifyTest <- function(out,expectedP, expectedT,
tol) {
if (assertEquals(expectedP, out$p.value, tol,
"Ttest p value")) {
displayPadded(output, SUCCEEDED, 80)
} else {
displayPadded(output, FAILED, 80)
}
output <- c("t test test statistic")
if (assertEquals(expectedT, out$statistic, tol,
"Ttest t statistic")) {
displayPadded(output, SUCCEEDED, 80)
} else {
displayPadded(output, FAILED, 80)
}
displayDashes(WIDTH)
}
cat("One-sample, two-sided TTest test cases \n")
sample1 <- c(93.0, 103.0, 95.0, 101.0, 91.0, 105.0, 96.0, 94.0, 101.0, 88.0,
98.0, 94.0, 101.0, 92.0, 95.0)
out <- t.test(sample1, mu=100.0)
expectedP <- 0.0136390585873
expectedT<- -2.81976445346
verifyTest(out,expectedP, expectedT, tol)
cat("One-sample, one-sided TTest test cases \n")
sample1 <- c(2, 0, 6, 6, 3, 3, 2, 3, -6, 6, 6, 6, 3, 0, 1, 1, 0, 2, 3, 3)
out <- t.test(sample1, mu=0.0, alternative="g")
expectedP <- 0.000521637019637
expectedT<- 3.86485535541
verifyTest(out,expectedP, expectedT, tol)
cat("Homoscedastic TTest test cases \n")
sample1 <- c(2, 4, 6, 8, 10, 97)
sample2 <- c(4, 6, 8, 10, 16)
out <- t.test(sample1,sample2,var.equal = TRUE)
expectedP <- 0.4833963785
expectedT<- 0.73096310086
verifyTest(out,expectedP, expectedT, tol)
cat("Heteroscedastic TTest test cases \n")
sample1 <- c(7, -4, 18, 17, -3, -5, 1, 10, 11, -2)
sample2 <- c(-1, 12, -1, -3, 3, -5, 5, 2, -11, -1, -3)
out <- t.test(sample1,sample2,var.equal = FALSE)
expectedP <- 0.128839369622
expectedT<- 1.60371728768
verifyTest(out,expectedP, expectedT, tol)
cat("Small sample, heteroscedastic test cases \n")
sample1 <- c(1,3)
sample2 <- c(4,5)
out <- t.test(sample1,sample2,var.equal = FALSE)
expectedP <- 0.198727388935
expectedT<- -2.2360679775
verifyTest(out,expectedP, expectedT, tol)
commons-math-2.2-src/src/test/R/FDistributionTestCases.R 100644 1750 1750 7735 11532241241 22002 0 ustar luc luc 0 0 # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#------------------------------------------------------------------------------
# R source file to validate F distribution tests in
# org.apache.commons.math.distribution.TDistributionTest
#
# To run the test, install R, put this file and testFunctions
# into the same directory, launch R from this directory and then enter
# source("")
#
#-----------------------------------------------------------------------------
tol <- 1E-9
# Function definitions
source("testFunctions") # utility test functions
# function to verify distribution computations
verifyDistribution <- function(points, expected, numeratorDf, denominatorDf, tol) {
rDistValues <- rep(0, length(points))
i <- 0
for (point in points) {
i <- i + 1
rDistValues[i] <- pf(point, numeratorDf, denominatorDf, log = FALSE)
}
output <- c("Distribution test numerator df = ", numeratorDf, " denominator df = ", denominatorDf)
if (assertEquals(expected, rDistValues, tol, "Distribution Values")) {
displayPadded(output, SUCCEEDED, WIDTH)
} else {
displayPadded(output, FAILED, WIDTH)
}
}
# function to verify density computations
verifyDensity <- function(points, expected, numeratorDf, denominatorDf, tol) {
rDensityValues <- rep(0, length(points))
i <- 0
for (point in points) {
i <- i + 1
rDensityValues[i] <- df(point, numeratorDf, denominatorDf, log = FALSE)
}
output <- c("Density test numerator df = ", numeratorDf, " denominator df = ", denominatorDf)
if (assertEquals(expected, rDensityValues, tol, "Density Values")) {
displayPadded(output, SUCCEEDED, WIDTH)
} else {
displayPadded(output, FAILED, WIDTH)
}
}
# function to verify quantiles
verifyQuantiles <- function(points, expected, numeratorDf, denominatorDf, tol) {
rQuantileValues <- rep(0, length(points))
i <- 0
for (point in points) {
i <- i + 1
rQuantileValues[i] <- qf(point, numeratorDf, denominatorDf, log = FALSE)
}
output <- c("Quantile test numerator df = ", numeratorDf, " denominator df = ", denominatorDf)
if (assertEquals(expected, rQuantileValues, tol, "Quantile Values")) {
displayPadded(output, SUCCEEDED, WIDTH)
} else {
displayPadded(output, FAILED, WIDTH)
}
}
#--------------------------------------------------------------------------
cat("F Distribution test cases\n")
numeratorDf <- 5
denominatorDf <- 6
distributionValues <- c(0.001, 0.01, 0.025, 0.05, 0.1, 0.999, 0.990, 0.975, 0.950, 0.900)
densityValues <- c(0.0689156576706, 0.236735653193, 0.364074131941, 0.481570789649, 0.595880479994,
0.000133443915657, 0.00286681303403, 0.00969192007502, 0.0242883861471, 0.0605491314658)
distributionPoints <- c(0.0346808448626, 0.0937009113303, 0.143313661184, 0.202008445998, 0.293728320107,
20.8026639595, 8.74589525602, 5.98756512605, 4.38737418741, 3.10751166664)
verifyQuantiles(distributionValues, distributionPoints, numeratorDf, denominatorDf, tol)
verifyDistribution(distributionPoints, distributionValues, numeratorDf, denominatorDf, tol)
verifyDensity(distributionPoints, densityValues, numeratorDf, denominatorDf, tol)
displayDashes(WIDTH)
commons-math-2.2-src/src/test/R/correlationTestCases 100644 1750 1750 24031 11532241241 21342 0 ustar luc luc 0 0 # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#------------------------------------------------------------------------------
# R source file to validate Pearson's correlation tests in
# org.apache.commons.math.stat.correlation.PearsonsCorrelationTest
#
# To run the test, install R, put this file and testFunctions
# into the same directory, launch R from this directory and then enter
# source("")
#
#------------------------------------------------------------------------------
tol <- 1E-15 # error tolerance for tests
#------------------------------------------------------------------------------
# Function definitions
source("testFunctions") # utility test functions
options(digits=16) # override number of digits displayed
# Verify Pearson's correlation
verifyPearsonsCorrelation <- function(matrix, expectedCorrelation, name) {
correlation <- cor(matrix)
output <- c("Pearson's Correlation matrix test dataset = ", name)
if (assertEquals(expectedCorrelation, correlation,tol,"Pearson's Correlations")) {
displayPadded(output, SUCCEEDED, WIDTH)
} else {
displayPadded(output, FAILED, WIDTH)
}
}
# Verify Spearman's correlation
verifySpearmansCorrelation <- function(matrix, expectedCorrelation, name) {
correlation <- cor(matrix, method="spearman")
output <- c("Spearman's Correlation matrix test dataset = ", name)
if (assertEquals(expectedCorrelation, correlation,tol,"Spearman's Correlations")) {
displayPadded(output, SUCCEEDED, WIDTH)
} else {
displayPadded(output, FAILED, WIDTH)
}
}
# function to verify p-values
verifyPValues <- function(matrix, pValues, name) {
dimension <- dim(matrix)[2]
corValues <- matrix(nrow=dimension,ncol=dimension)
expectedValues <- matrix(nrow=dimension,ncol=dimension)
for (i in 2:dimension) {
for (j in 1:(i-1)) {
corValues[i,j]<-cor.test(matrix[,i], matrix[,j])$p.value
corValues[j,i]<-corValues[i,j]
}
}
for (i in 1:dimension) {
corValues[i,i] <- 1
expectedValues[i,i] <- 1
}
ptr <- 1
for (i in 2:dimension) {
for (j in 1:(i-1)) {
expectedValues[i,j] <- pValues[ptr]
expectedValues[j,i] <- expectedValues[i,j]
ptr <- ptr + 1
}
}
output <- c("Correlation p-values test dataset = ", name)
if (assertEquals(expectedValues, corValues,tol,"p-values")) {
displayPadded(output, SUCCEEDED, WIDTH)
} else {
displayPadded(output, FAILED, WIDTH)
}
}
#--------------------------------------------------------------------------
cat("Correlation test cases\n")
# Longley -----------------------------------------------------------------
longley <- matrix(c(60323,83.0,234289,2356,1590,107608,1947,
61122,88.5,259426,2325,1456,108632,1948,
60171,88.2,258054,3682,1616,109773,1949,
61187,89.5,284599,3351,1650,110929,1950,
63221,96.2,328975,2099,3099,112075,1951,
63639,98.1,346999,1932,3594,113270,1952,
64989,99.0,365385,1870,3547,115094,1953,
63761,100.0,363112,3578,3350,116219,1954,
66019,101.2,397469,2904,3048,117388,1955,
67857,104.6,419180,2822,2857,118734,1956,
68169,108.4,442769,2936,2798,120445,1957,
66513,110.8,444546,4681,2637,121950,1958,
68655,112.6,482704,3813,2552,123366,1959,
69564,114.2,502601,3931,2514,125368,1960,
69331,115.7,518173,4806,2572,127852,1961,
70551,116.9,554894,4007,2827,130081,1962),
nrow = 16, ncol = 7, byrow = TRUE)
# Pearson's
expectedCorrelation <- matrix(c(
1.000000000000000, 0.9708985250610560, 0.9835516111796693, 0.5024980838759942,
0.4573073999764817, 0.960390571594376, 0.9713294591921188,
0.970898525061056, 1.0000000000000000, 0.9915891780247822, 0.6206333925590966,
0.4647441876006747, 0.979163432977498, 0.9911491900672053,
0.983551611179669, 0.9915891780247822, 1.0000000000000000, 0.6042609398895580,
0.4464367918926265, 0.991090069458478, 0.9952734837647849,
0.502498083875994, 0.6206333925590966, 0.6042609398895580, 1.0000000000000000,
-0.1774206295018783, 0.686551516365312, 0.6682566045621746,
0.457307399976482, 0.4647441876006747, 0.4464367918926265, -0.1774206295018783,
1.0000000000000000, 0.364416267189032, 0.4172451498349454,
0.960390571594376, 0.9791634329774981, 0.9910900694584777, 0.6865515163653120,
0.3644162671890320, 1.000000000000000, 0.9939528462329257,
0.971329459192119, 0.9911491900672053, 0.9952734837647849, 0.6682566045621746,
0.4172451498349454, 0.993952846232926, 1.0000000000000000),
nrow = 7, ncol = 7, byrow = TRUE)
verifyPearsonsCorrelation(longley, expectedCorrelation, "longley")
expectedPValues <- c(
4.38904690369668e-10,
8.36353208910623e-12, 7.8159700933611e-14,
0.0472894097790304, 0.01030636128354301, 0.01316878049026582,
0.0749178049642416, 0.06971758330341182, 0.0830166169296545, 0.510948586323452,
3.693245043123738e-09, 4.327782576751815e-11, 1.167954621905665e-13, 0.00331028281967516, 0.1652293725106684,
3.95834476307755e-10, 1.114663916723657e-13, 1.332267629550188e-15, 0.00466039138541463, 0.1078477071581498, 7.771561172376096e-15)
verifyPValues(longley, expectedPValues, "longley")
# Spearman's
expectedCorrelation <- matrix(c(
1, 0.982352941176471, 0.985294117647059, 0.564705882352941, 0.2264705882352941, 0.976470588235294,
0.976470588235294, 0.982352941176471, 1, 0.997058823529412, 0.664705882352941, 0.2205882352941176,
0.997058823529412, 0.997058823529412, 0.985294117647059, 0.997058823529412, 1, 0.638235294117647,
0.2235294117647059, 0.9941176470588236, 0.9941176470588236, 0.564705882352941, 0.664705882352941,
0.638235294117647, 1, -0.3411764705882353, 0.685294117647059, 0.685294117647059, 0.2264705882352941,
0.2205882352941176, 0.2235294117647059, -0.3411764705882353, 1, 0.2264705882352941, 0.2264705882352941,
0.976470588235294, 0.997058823529412, 0.9941176470588236, 0.685294117647059, 0.2264705882352941, 1, 1,
0.976470588235294, 0.997058823529412, 0.9941176470588236, 0.685294117647059, 0.2264705882352941, 1, 1),
nrow = 7, ncol = 7, byrow = TRUE)
verifySpearmansCorrelation(longley, expectedCorrelation, "longley")
# Swiss Fertility ---------------------------------------------------------
fertility <- matrix(c(80.2,17.0,15,12,9.96,
83.1,45.1,6,9,84.84,
92.5,39.7,5,5,93.40,
85.8,36.5,12,7,33.77,
76.9,43.5,17,15,5.16,
76.1,35.3,9,7,90.57,
83.8,70.2,16,7,92.85,
92.4,67.8,14,8,97.16,
82.4,53.3,12,7,97.67,
82.9,45.2,16,13,91.38,
87.1,64.5,14,6,98.61,
64.1,62.0,21,12,8.52,
66.9,67.5,14,7,2.27,
68.9,60.7,19,12,4.43,
61.7,69.3,22,5,2.82,
68.3,72.6,18,2,24.20,
71.7,34.0,17,8,3.30,
55.7,19.4,26,28,12.11,
54.3,15.2,31,20,2.15,
65.1,73.0,19,9,2.84,
65.5,59.8,22,10,5.23,
65.0,55.1,14,3,4.52,
56.6,50.9,22,12,15.14,
57.4,54.1,20,6,4.20,
72.5,71.2,12,1,2.40,
74.2,58.1,14,8,5.23,
72.0,63.5,6,3,2.56,
60.5,60.8,16,10,7.72,
58.3,26.8,25,19,18.46,
65.4,49.5,15,8,6.10,
75.5,85.9,3,2,99.71,
69.3,84.9,7,6,99.68,
77.3,89.7,5,2,100.00,
70.5,78.2,12,6,98.96,
79.4,64.9,7,3,98.22,
65.0,75.9,9,9,99.06,
92.2,84.6,3,3,99.46,
79.3,63.1,13,13,96.83,
70.4,38.4,26,12,5.62,
65.7,7.7,29,11,13.79,
72.7,16.7,22,13,11.22,
64.4,17.6,35,32,16.92,
77.6,37.6,15,7,4.97,
67.6,18.7,25,7,8.65,
35.0,1.2,37,53,42.34,
44.7,46.6,16,29,50.43,
42.8,27.7,22,29,58.33),
nrow = 47, ncol = 5, byrow = TRUE)
# Pearson's
expectedCorrelation <- matrix(c(
1, 0.3530791836199747, -0.6458827064572875, -0.663788857035069, 0.463684700651794,
0.3530791836199747, 1, -0.6865422086171366, -0.63952251894832, 0.4010950530487398,
-0.6458827064572875, -0.6865422086171366, 1, 0.698415296288483, -0.572741806064167,
-0.663788857035069, -0.63952251894832, 0.698415296288483, 1, -0.1538589170909148,
0.463684700651794, 0.4010950530487398, -0.572741806064167, -0.1538589170909148, 1),
nrow = 5, ncol = 5, byrow = TRUE)
verifyPearsonsCorrelation(fertility, expectedCorrelation, "swiss fertility")
expectedPValues <- c(
0.01491720061472623,
9.45043734069043e-07, 9.95151527133974e-08,
3.658616965962355e-07, 1.304590105694471e-06, 4.811397236181847e-08,
0.001028523190118147, 0.005204433539191644, 2.588307925380906e-05, 0.301807756132683)
verifyPValues(fertility, expectedPValues, "swiss fertility")
# Spearman's
expectedCorrelation <- matrix(c(
1, 0.2426642769364176, -0.660902996352354, -0.443257690360988, 0.4136455623012432,
0.2426642769364176, 1, -0.598859938748963, -0.650463814145816, 0.2886878090882852,
-0.660902996352354, -0.598859938748963, 1, 0.674603831406147, -0.4750575257171745,
-0.443257690360988, -0.650463814145816, 0.674603831406147, 1, -0.1444163088302244,
0.4136455623012432, 0.2886878090882852, -0.4750575257171745, -0.1444163088302244, 1),
nrow = 5, ncol = 5, byrow = TRUE)
verifySpearmansCorrelation(fertility, expectedCorrelation, "swiss fertility")
displayDashes(WIDTH)
commons-math-2.2-src/src/test/R/binomialTestCases 100644 1750 1750 11107 11532241241 20613 0 ustar luc luc 0 0 # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#------------------------------------------------------------------------------
# R source file to validate Binomial distribution tests in
# org.apache.commons.math.distribution.BinomialDistributionTest
#
# To run the test, install R, put this file and testFunctions
# into the same directory, launch R from this directory and then enter
# source("")
#
# R functions used
# dbinom(x, size, prob, log = FALSE) <- density
# pbinom(q, size, prob, lower.tail = TRUE, log.p = FALSE) <- distribution
# qbinom(p, size, prob, lower.tail = TRUE, log.p = FALSE) <- quantiles
#------------------------------------------------------------------------------
tol <- 1E-4 # error tolerance for tests
#------------------------------------------------------------------------------
# Function definitions
source("testFunctions") # utility test functions
# function to verify density computations
verifyDensity <- function(points, expected, n, p, tol) {
rDensityValues <- rep(0, length(points))
i <- 0
for (point in points) {
i <- i + 1
rDensityValues[i] <- dbinom(point, n, p, log = FALSE)
}
output <- c("Density test n = ", n, ", p = ", p)
if (assertEquals(expected,rDensityValues,tol,"Density Values")) {
displayPadded(output, SUCCEEDED, WIDTH)
} else {
displayPadded(output, FAILED, WIDTH)
}
}
# function to verify distribution computations
verifyDistribution <- function(points, expected, n, p, tol) {
rDistValues <- rep(0, length(points))
i <- 0
for (point in points) {
i <- i + 1
rDistValues[i] <- pbinom(point, n, p, log = FALSE)
}
output <- c("Distribution test n = ", n, ", p = ", p)
if (assertEquals(expected,rDistValues,tol,"Distribution Values")) {
displayPadded(output, SUCCEEDED, WIDTH)
} else {
displayPadded(output, FAILED, WIDTH)
}
}
#--------------------------------------------------------------------------
cat("Binomial test cases\n")
size <- 10.0
probability <- 0.70
densityPoints <- c(-1,0,1,2,3,4,5,6,7,8,9,10,11)
densityValues <- c(0, 0.0000, 0.0001, 0.0014, 0.0090, 0.0368, 0.1029,
0.2001, 0.2668, 0.2335, 0.1211, 0.0282, 0)
distributionValues <- c(0, 0.0000, 0.0001, 0.0016, 0.0106, 0.0473,
0.1503, 0.3504, 0.6172, 0.8507, 0.9718, 1, 1)
inverseCumPoints <- c( 0.001, 0.010, 0.025, 0.050, 0.100, 0.999,
0.990, 0.975, 0.950, 0.900)
inverseCumValues <- c(1, 2, 3, 4, 4, 9, 9, 9, 8, 8)
verifyDensity(densityPoints,densityValues,size,probability,tol)
verifyDistribution(densityPoints, distributionValues, size, probability, tol)
i <- 0
rInverseCumValues <- rep(0,length(inverseCumPoints))
for (point in inverseCumPoints) {
i <- i + 1
rInverseCumValues[i] <- qbinom(point, size, probability, log = FALSE)
}
output <- c("Inverse Distribution test n = ", size, ", p = ", probability)
# R defines quantiles from the right, need to subtract one
if (assertEquals(inverseCumValues, rInverseCumValues-1, tol,
"Inverse Dist Values")) {
displayPadded(output, SUCCEEDED, 80)
} else {
displayPadded(output, FAILED, 80)
}
# Degenerate cases
size <- 5
probability <- 0.0
densityPoints <- c(-1, 0, 1, 10, 11)
densityValues <- c(0, 1, 0, 0, 0)
distributionPoints <- c(-1, 0, 1, 5, 10)
distributionValues <- c(0, 1, 1, 1, 1)
verifyDensity(densityPoints,densityValues,size,probability,tol)
verifyDistribution(distributionPoints,distributionValues,size,probability,tol)
size <- 5
probability <- 1.0
densityPoints <- c(-1, 0, 1, 2, 5, 10)
densityValues <- c(0, 0, 0, 0, 1, 0)
distributionPoints <- c(-1, 0, 1, 2, 5, 10)
distributionValues <- c(0, 0, 0, 0, 1, 1)
verifyDensity(densityPoints,densityValues,size,probability,tol)
verifyDistribution(distributionPoints,distributionValues,size,probability,tol)
displayDashes(WIDTH)
commons-math-2.2-src/src/test/resources/org/apache/commons/math/random/emptyFile.txt 100644 1750 1750 0 11532241244 27354 0 ustar luc luc 0 0 commons-math-2.2-src/src/test/resources/org/apache/commons/math/random/testData.txt 100644 1750 1750 43270 11532241244 27307 0 ustar luc luc 0 0 4.038625496201205
3.6485326248346936
3.6651209675932845
5.814896279561131
5.384126469824717
5.251190723365563
4.465213440111648
4.736608014129308
5.566383814840726
3.8872277480629114
5.246598498086048
3.7511487364188176
6.733371385175343
5.388632419618035
6.036263402962769
3.8105605069222905
5.738599503606028
4.994552792425298
2.945504336988336
4.095314381239862
5.760924710543879
3.889753944419315
3.808861160991701
5.084302950012555
6.370292933705698
5.9615431859588455
4.8790354385481445
4.068164663649243
4.26491661935213
5.911067976258105
4.1316140545022115
4.0479985648577115
5.560425919351912
5.7777862258090265
4.6491664757229145
5.322284766164775
3.9643060017297818
3.3374606422520423
4.070818520139152
5.162814971692577
4.68959876937858
5.729533112912969
7.160010937980058
5.154920628387343
5.992604820701763
5.317279162752973
6.3388993007264
4.38451874656454
5.024014917973479
3.7534872319471946
5.042363342784924
5.528064915562473
4.645749024871185
2.5572755520373756
3.953716919712825
3.479482401208564
4.676100783445583
4.602236051449888
7.136692300563229
3.2411466558895095
4.188618724984135
3.6403999184454445
3.4104206071160776
4.807963390662261
4.039073733966207
4.201017826594899
4.381868005163936
5.0635235098658935
5.9840760229548735
4.195400406346137
5.649256144660377
4.679088153774095
4.169683379901892
5.671299804360453
6.159089864893807
5.315685219074694
6.3327786025390305
5.57348047674858
6.124073677151904
4.599177837977919
4.792320274522308
5.670142645005109
5.479531549270221
4.7740747976996705
4.99464290442364
5.474337090086012
5.232353744280737
6.411298157619626
4.757268066271138
5.217779158748026
5.07395379944902
5.5759984176628965
4.521182520094989
5.738026445940142
4.742204968903384
4.670762511507285
4.884925361512115
3.2573282568729462
4.548387675110013
4.337950021352034
3.7875587274144618
3.6055586455442974
7.361861332197413
4.834945622163155
6.019473054836964
4.453304225895349
3.258695681592217
5.794572588445252
3.706438851580378
6.079300672323756
4.828008457182361
5.315261102210712
3.981847695058188
4.039767325290114
5.790863349525503
5.160671471128728
4.835236459763434
4.405281184174698
6.036293520404953
5.889067983920324
4.645514887430352
4.347244670972515
6.447181244432997
6.564267268399325
5.1013992003059885
4.123378901103389
2.7101740954226283
4.209200680057913
5.085704888132955
4.26810090240086
5.54254381015526
4.721081268239747
6.890088385585999
3.9983110493877954
5.321006894021748
4.316867375040024
3.694764624577479
5.453875921043777
3.7798857421649927
3.7228653199742623
4.807698651287013
3.953745662132547
4.821189486606762
4.453489509051613
6.4517275696030225
4.823034188588044
4.722822481625316
5.810689805246644
2.79248319144007
4.928162269110059
4.661918219482871
4.574123379557206
5.241478194631993
5.8345087395944155
7.024415739565572
3.5536052565954
6.095523994939967
5.714650096778455
4.846741263282074
6.002769586957791
5.982356840660745
5.045480762532407
6.461077219605347
4.806649266171423
6.350848113862498
6.402679936682352
3.8190196431210914
4.189064677946727
4.868517260374518
2.145198341547173
5.9469461091347
5.88772432287321
4.258280909990726
6.740134075161574
4.6047650031608445
3.9273659909763774
4.291244045368331
5.183827109845055
5.696810583954774
3.608472134466666
4.169004030425733
3.9965477474540467
3.7571221568428017
5.575534565152322
5.0764208309825065
5.3185446180363485
5.157450995663762
4.961815558094033
5.687338919107788
4.185906295178724
4.382007991332045
3.5280961455873676
4.531506809760329
4.5870808989545635
4.1932173503939625
7.213813469684956
3.1814836225682908
4.647297462243001
5.223975935315364
5.585001659776854
5.120918864744974
5.026571594328509
6.348097968923147
6.50023470519147
5.712556147497515
5.206026515338916
5.749621140061565
3.0714726650374033
6.576852312067237
7.873101351668455
6.565410149266118
6.42923283018875
4.576910183319347
4.891822273316748
6.059357175219146
3.5324494806223328
5.02539429500825
6.078049839679652
4.395054417468175
5.710022806162443
5.577091376894232
3.131753802875934
5.4869998928318
6.413992453090146
6.368380820674971
6.052068461844252
5.480278219624535
7.051236227914206
4.748415087916627
4.559239556696287
4.780665068784505
5.349223485326002
4.522305152002386
5.678473361027541
6.734219964637535
6.713281662687456
6.22214905332774
5.716102543806569
6.336616632829493
4.8399311234283635
5.811391244308217
4.3965755331585905
5.297963707368242
5.021726117260926
4.497125082388555
4.735667209277485
6.048804114181307
4.264048138073914
7.181013762432201
4.781684059171574
5.779533272721499
4.164421460389599
3.6986809242837757
4.8415576143236185
4.924528568365373
4.758045335351253
5.628351489493518
5.7967639104855415
4.491988822693669
2.776750089391839
4.704679957076673
4.039607278211126
5.660350110077993
4.955611684289963
3.0641653090331107
4.896101875253389
3.6528358436331603
5.552472713484715
4.857203367367906
6.698826102960048
4.485176970803183
3.359916665137426
4.036570806638963
3.48793689188148
4.19214761961293
3.9792199677002866
6.760873252923419
4.333561067615548
5.018626873497648
3.377671327382937
4.426183834007672
8.806961710969402
5.2068790380550265
5.483008251803699
4.287267636533901
5.931330465014387
5.257260104496106
4.623908313559696
4.365112456604631
5.600514050451817
6.184093404453588
4.9116883675838485
6.019780977080248
7.485280872899538
3.5982660410679284
4.232210941334369
5.446496617538108
6.487976163896015
3.3960660696641156
4.733884295853101
5.352545256764909
4.107747627715545
3.949506252011129
5.017847997679714
4.24906287118262
6.720303792581198
5.832137142236708
5.010377506040941
6.458070081692352
6.501223021355141
4.612768564431788
3.801740464538825
4.469721893125596
5.061713024524103
6.872685648715577
6.145993249521355
4.638532388190405
4.70471535512485
6.417576222531886
4.118577249932789
4.431328683019108
4.747884983644578
4.495605382683923
3.5972439735401767
5.210796056817244
2.9160129894156026
3.4596190721900797
3.972452277026154
5.5237190584690214
6.104711796147512
4.787324556447702
4.548676032231089
6.356843891618192
3.6148998030697816
4.760679260180754
4.698041709266617
4.244003753086054
5.595546833817678
3.2784025595193267
5.326657347561453
6.213858447402109
5.213011705084566
7.232075882741927
4.806572191866972
4.680144670146755
3.946663831660007
3.6143084085883554
7.789315918667734
7.099181638561095
3.672742516732736
5.953845998789752
6.28847712720666
6.946689084108734
6.325454389782429
4.334133006331358
3.039424552213366
4.847328734611504
4.249781519880862
6.126424188695286
3.3823135936253257
6.3280255743100025
6.150431997847958
5.4226742397784005
5.94864601826791
4.425906835511732
4.897545227095195
6.26027333638832
3.647858418615367
5.276322437292433
4.176876069581277
4.346107259567459
3.1384418250329995
4.212957347421948
4.637757894698186
6.535589923573854
5.193072556110316
5.017309492685374
5.1750466093509
4.6381038872450375
6.071604634493695
4.357240286904764
5.122391923621759
6.556903940099011
3.8006848201076036
4.522363890394659
6.2456602471550635
5.829300589393535
4.452647643620209
5.371890862621703
4.948677662633424
5.661113800822228
5.773629402623548
6.139823333391851
6.093004328053013
5.362399773949667
6.915042845179306
5.394739321037944
5.141451574018252
5.053294383161769
4.9834920876470665
6.812746808763125
3.5705971688428266
4.664119854301202
6.310596552569324
5.674835228932813
3.4639740645984807
4.788956793299906
5.1005488900135845
4.534989910256703
3.931742089464332
3.572625977535623
5.374511045697475
3.859408179493194
5.767053789854141
5.1414168750827285
4.7490168496463525
7.481142748403815
4.5189492261011575
5.40235395980428
6.700234279658992
3.5063554778412183
3.9690452319798735
3.00630763890251
7.23611608840341
5.018006325958164
4.523410620276403
4.076684362167451
5.916234395538267
7.047286572236027
3.8682363461132017
4.390658924201581
4.5292330092964255
5.07906584568947
4.671213490610071
4.095193931403399
4.054590162572947
3.2227278245030027
6.132646335444107
2.8407359953623814
4.7279370282096655
5.593872406613741
3.382542536766184
5.85844025043303
6.461000354065181
3.4994741020969773
4.132683344034104
5.647894883473891
5.011301190267978
4.401435886120444
3.3496957519609927
6.119687677370172
4.644762759286699
4.5205629205178735
3.0320051244977195
4.596487037061894
5.14520534308978
5.282269168918912
5.761372455401502
4.148416743583162
6.372742039103559
5.649143130777574
5.084494528193606
4.811163551671385
3.9806520282362476
4.411511792047385
4.670987670787611
5.768451736319585
3.984558689428816
5.3293696591099975
5.413539058295544
6.40970782426591
5.481145473625602
4.36515208836978
5.161811987273001
3.963554978392394
5.098946908474979
7.786683053797615
4.927631219070586
5.524180021898693
4.523736107490982
3.557364094609177
6.128701594561169
4.2509207146594115
3.944944115965259
4.966138264389299
5.394430219583224
6.77531735530901
4.128069102169693
5.2683457909620355
3.8872836447608496
4.486696800422189
6.5335585640393825
4.916400608546338
4.270979919569207
4.311416898242187
4.498167295277512
6.132808180917634
5.1041291367018875
5.498388642491546
5.584526454067219
6.142894025331306
4.944671156061267
4.1686843376349945
4.818977261651865
6.235820918635881
3.3212806573760028
5.68435151611855
6.189749316228399
3.591267557367338
5.043902793214377
7.818905185451641
4.768708643560666
5.669288800286096
6.398657810380692
5.3717200778027605
5.2573487416126525
4.822935237131512
6.182572962936934
5.6072955002277105
3.9675191626756288
6.350858167126948
6.283995295688788
4.445782391191543
6.877548745307459
5.3208290700871315
6.09847688940267
6.434994026138841
4.32779758193763
7.2924037238697
5.419935895280957
4.288818201810987
7.242433265647824
4.947890367713541
5.916218606455959
6.490437527083841
4.617582424838291
7.957708355752131
4.879357620439287
6.103294400805588
5.639488259504568
4.335236791293937
5.202542624850618
5.4406339076225505
5.782530244910674
4.055314639567904
5.552293301411749
5.290496801505254
4.022580394801182
4.625571974654451
5.5086593656510825
4.913637297182931
4.906396844626936
6.439485089212817
5.7942799739945325
7.158136207286507
4.280431104751667
3.9206066719991517
5.127791240556268
6.70098532482022
4.657147097255419
4.524267698037553
4.647534545829241
4.839690189371444
6.798322548455047
5.094754599613737
5.916399329150566
5.767837713902285
5.294550523894544
4.161295164684424
5.233358678928891
5.546871474458429
4.897048191655597
3.939430251326603
5.005888208270397
3.2926576330038655
4.0159694347757835
5.056229917378723
6.568879235955665
4.497327615853924
4.690014685240942
4.746884105330737
4.841384111334085
4.14796180246966
5.461902744235217
5.869304766250897
3.52354738655413
5.582741221891035
4.997825621424692
5.439611672191855
4.819402835865619
5.76136287301575
6.143090288547951
5.976125217642891
6.157007787875113
4.912778652906766
6.540414953620538
3.8210262932626495
4.727149320768898
4.955255599543759
5.7983414047818265
5.167409288825197
5.059246623397723
6.965380962189423
5.531311904089661
5.4022568784996885
4.344352255655229
5.745261070226892
5.118820012265567
4.960430609470355
4.487905086804239
3.8537512154805835
4.839114062528739
5.367538410451759
6.202050661574205
4.001800559371117
6.119617239220475
3.236283913097008
5.610134770285298
5.757041556538514
4.083399027093518
5.055588718117847
4.580930359877383
6.545516697552579
5.916270431823864
3.761559453909257
6.037777237143994
7.29718541816528
4.8965176227762734
3.941358569293476
3.9289815988008847
3.2604315357316436
4.639329221347256
6.570997662310685
3.851958625190621
5.859087244914328
4.647365626452129
6.076778087850363
4.627936340272149
4.422345848512504
6.2183675417422
5.243889853389288
5.90909311946919
6.09260484846961
6.0271781583360475
6.913810502971691
5.285845705409185
5.318460367681083
5.179580543035928
4.6834977896331615
5.382546996207003
4.606307320228796
4.038858683454586
6.271279252908354
6.0668723017439365
5.713564644555386
5.144428649779485
5.2496039700779615
3.8392027391676207
4.7050632415088876
7.137275712725372
4.208879180827962
4.81480733241727
4.699941077536472
4.423440083005291
5.742161495602944
4.592506326637019
6.224046541049566
4.611093653533141
6.1166037746546165
5.904004955760586
5.589433336321981
4.57489510266225
5.500028469975376
4.382479722617695
4.257470376496386
6.373209588018213
5.375461447759072
2.8662337475774584
4.699832117278568
3.102810935311515
6.501460955698313
4.550333534073201
7.944860661426514
5.69020177364993
4.006199611798767
5.11813341012065
4.896479097282944
4.816212778128475
4.940296064591277
5.419056166663748
3.4659391357743616
7.246324501631043
5.907112751874067
5.614502217435809
4.750614593197476
7.0951293897280205
4.3819944682346055
4.958360318480322
4.962367933857186
5.715499159595656
5.220101872658552
6.088622700649866
5.491586360474799
4.656477235994459
3.8695533953710326
3.7143742249025538
3.7411936672155304
6.603415889834424
5.62928670505705
5.5959396553858785
5.6577330557176095
6.003846653929077
4.508563176717718
5.549881486113916
4.953305865372426
6.203554032873964
5.612208234244517
4.854464793588011
5.263585016371758
3.897600440182904
5.981235398882815
5.531277293213279
4.8817070690071445
3.712544699529063
3.513432242611217
5.006035295792077
7.124520658535316
3.4782033127607037
4.829578059223972
5.742892584711905
4.361333503197903
4.601687049512891
6.035189727259647
4.711273209758127
4.272043208125593
4.447702393976457
5.17487393756583
4.741015989802225
4.953808452791662
4.6645084492292765
4.276788530554644
7.325515154525428
4.602597440231014
5.082884146093998
3.068409439905545
4.809983425115099
3.8747882947708083
4.893233436073575
5.376932606908371
6.239910432522629
6.041695571547008
5.317735375674715
5.160517819092331
5.283748111202239
6.5357867130743745
5.537247902605441
5.4185896683530235
5.287616337544387
5.981700012459223
5.992385624329782
5.758772999982491
4.599744432168506
5.7237660286844605
2.5862937961454855
4.319918124665613
7.566860260437548
3.202784785619934
6.67642720284947
5.215802050091852
5.452814592454087
4.192858032386887
5.299199379721475
3.291677765243241
4.632695766333648
5.115714853147839
4.996260485718097
3.5271286032511773
4.659715887897552
6.587392147323261
5.989132075359954
3.8378063660060056
4.975951043892332
3.90853196371359
5.708783809093124
6.591895462100242
5.653528117636727
3.665428787393319
4.324537690925271
6.234413976864244
4.053504794002944
5.713371183460703
4.670243561862966
3.352660528859447
4.020147292531281
5.121933145078237
4.282377411958472
4.088770874857499
4.275716553910016
4.284046155337823
6.449567142111275
3.3275914286077084
4.837717853228399
5.261182985672333
6.073443097165901
5.40483608136289
4.690566013556853
4.222184746341714
5.790245443382679
5.020060832906476
5.576527321711127
5.340393035828579
5.301460661931292
5.076040366457228
6.296482877500045
3.037720796600903
6.321850760102656
5.701339165316606
4.991940459105436
5.758970102557518
4.322111367356909
5.721255109646473
5.511881303620453
4.9563635195228954
6.861001584068987
3.8299029968884195
4.322974731453332
5.3047403550360634
6.0756269754391825
6.117153630436378
4.5085862451026495
4.832132638553977
4.699215334058029
7.982648077178181
3.303778194960711
6.845166964779691
5.175136241842978
5.611538016661082
4.293354218279116
6.2617605857039775
4.646868778200023
5.596211970851805
6.4731028962866635
5.9737535333484795
6.411386536458501
2.7695062051965302
3.5560570906765894
5.451690061978083
6.503535887841675
4.695530301460264
4.706120568510652
2.800841111510871
5.364729318170148
5.1911558656154835
5.947415408072919
4.777513714112934
4.596459418828304
5.043317097051506
5.174749896541634
5.258257882159918
3.887023257269741
5.131383317673293
5.843231353166214
6.472487193651527
5.763704927517821
6.024396779444038
4.926879229092987
6.558645082464584
5.447575064546803
4.286751335276036
3.9071252303818644
4.618489035299945
5.088217807208579
3.808752600228301
5.861810119867259
4.033532296400091
5.74542761207288
4.925806147050348
3.679404591586196
4.05604604887352
5.87881882930846
4.513573760688276
4.915009783906388
3.654483449601882
4.912095784340134
3.3774256594506396
4.188548007093734
5.4860540834510445
4.483111427918742
6.091604204270534
4.913639044459108
6.347957296069254
5.777137740280461
4.996625717628335
3.357832000765961
4.529640780144531
6.655383658310578
5.187418414545693
5.275067584707507
5.50723064248028
4.636201988408981
4.947416066568987
7.027581910469225
4.570962245627946
5.947355941474328
4.7057667163042245
4.786943520378938
5.615852784022176
4.645129057815488
5.263882354785195
3.844951724466573
5.554260404852657
4.684091248268045
5.13336102667963
3.417837773686996
4.392489033666552
6.270027300253521
6.102372796945901
4.219653651099504
5.076173402237902
4.383422445264855
3.0437995085361025
5.377941796580727
6.276975902314367
4.315133675763909
5.507204150696545
4.886780791403244
7.147240935203286
3.900457465197911
5.102470142455588
7.084247234995372
5.457300111792919
4.60867925423519
6.2840312118540815
7.236947706509271
7.133509547170027
4.3015318378968
5.043756433592529
5.108881706267525
5.5240023845728645
5.858632364389344
5.981971317600007
6.259948473084726
4.062783955426871
5.218852203995356
3.8038254404258813
4.758585778361602
4.376196481713867
4.458880802424765
3.96326498727664
3.6778134622710104
4.374934998721925
7.489468914416122
5.700987063590436
3.3100952240676955
5.1696122166092415
6.541584919841012
4.4595571152023465
4.366611842258099
5.382259676070623
4.7794428978336825
3.757838857759169
6.545307984939696
4.881890171568036
5.7063933726311165
4.7730257133517116
3.873677842944983
3.840259191338565
4.593661080441791
4.511107632929962
5.5385052402039605
5.441167937479936
5.984890322415174
5.403820054129332
5.148546201719365
4.838476271562129
6.2440438844133075
3.9741885421050913
6.327490860577795
4.633940514497735
5.232122748521683
4.456999940494487
5.576626928088951
3.2818610857426584
5.134684374559793
4.602466559265273
5.891324885962796
5.517816321593768
6.624687761337339
5.2683180340267874
4.662418552035468
4.622236368091395
5.536060664096081
3.272870360657461
3.9899131914173696
5.121549579739896
5.928806028927443
4.259133981719825
5.313734011651727
5.635277610987355
4.524627655490917
commons-math-2.2-src/src/test/resources/org/apache/commons/math/stat/data/Lew.txt 100644 1750 1750 7025 11532241244 26647 0 ustar luc luc 0 0 #####################################################################
# Dataset Name: Lew (Beam Deflection Data)
#
# Description: This is an observed/"real world" data set
# consisting of 200 deflections of a steel-concrete
# beam while subjected to periodic pressure.
# The experimenter was H. S. Lew of the
# Center for Building Technology at NIST.
# We here use this data to test accuracy
# in summary statistics calculations.
#
# Stat Category: Univariate: Summary Statistics
#
# Reference: http://www.itl.nist.gov/div898/strd/univ/lew.html
#
# Data: "Real World"
# 1 Response : y = beam deflection
# 0 Predictors
# 200 Observations
#
# Model: Lower Level of Difficulty
# 2 Parameters : mu, sigma
# 1 Response Variable : y
# 0 Predictor Variables
# y = mu + e
#####################################################################
#####################################################################
#
# Certified Values
#
#####################################################################
n = 200
mean = -177.435000000000
standardDeviation = 277.332168044316
autocorrelationCoefficient = -0.307304800605679
#####################################################################
#
# R Generated Values
#
#####################################################################
variance = 76913.13143
max = 300
min = -579
sum = -35487
#####################################################################
#
# Data
#
#####################################################################
-213
-564
-35
-15
141
115
-420
-360
203
-338
-431
194
-220
-513
154
-125
-559
92
-21
-579
-52
99
-543
-175
162
-457
-346
204
-300
-474
164
-107
-572
-8
83
-541
-224
180
-420
-374
201
-236
-531
83
27
-564
-112
131
-507
-254
199
-311
-495
143
-46
-579
-90
136
-472
-338
202
-287
-477
169
-124
-568
17
48
-568
-135
162
-430
-422
172
-74
-577
-13
92
-534
-243
194
-355
-465
156
-81
-578
-64
139
-449
-384
193
-198
-538
110
-44
-577
-6
66
-552
-164
161
-460
-344
205
-281
-504
134
-28
-576
-118
156
-437
-381
200
-220
-540
83
11
-568
-160
172
-414
-408
188
-125
-572
-32
139
-492
-321
205
-262
-504
142
-83
-574
0
48
-571
-106
137
-501
-266
190
-391
-406
194
-186
-553
83
-13
-577
-49
103
-515
-280
201
300
-506
131
-45
-578
-80
138
-462
-361
201
-211
-554
32
74
-533
-235
187
-372
-442
182
-147
-566
25
68
-535
-244
194
-351
-463
174
-125
-570
15
72
-550
-190
172
-424
-385
198
-218
-536
96
commons-math-2.2-src/src/test/resources/org/apache/commons/math/stat/data/NumAcc3.txt 100644 1750 1750 32664 11532241244 27400 0 ustar luc luc 0 0 File Name: NumAcc3.dat
File Format: ASCII
Header : lines 1 to 60 (= 60)
Certified Values: lines 41 to 43 (= 3)
Data : lines 61 to 1061 (= 1001)
Dataset Name: NumAcc3
Description: This is a constructed/fabricated data set
to test accuracy in summary statistic calculations.
The numbers are 8-digit floating point values and
differ only in the last decimal place.
Note--by construction, this data set has
sample mean = 1000000.2 (exact)
sample standard dev. = 0.1 (exact)
sample autocorr. coef. = -0.999 (exact)
Stat Category: Univariate: Summary Statistics
Reference: Simon, Stephen D. and Lesage, James P. (1989).
Assessing the Accuracy of ANOVA Caluclations
in Statistical Software", Computational
Statistics & data Analysis, 8, pp. 325-332.
Data: Constructed
1 Response : y
0 Predictors
1001 Observations
Model: Average Level of Difficulty
2 Parameters : mu, sigma
1 Response Variable : y
0 Predictor Variables
y = mu + e
Certified Values
Sample Mean ybar: 1000000.2
Sample Standard Deviation (denom. = n-1) s: 0.1
Sample Autocorrelation Coefficient (lag 1) r(1): -0.999
Number of Observations: 1001
Data: Y
-------------
1000000.2
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
1000000.1
1000000.3
commons-math-2.2-src/src/test/resources/org/apache/commons/math/stat/data/PiDigits.txt 100644 1750 1750 120645 11532241244 27700 0 ustar luc luc 0 0 File Name: PiDigits.dat
File Format: ASCII
Header : lines 1 to 60 (= 60)
Certified Values: lines 41 to 43 (= 3)
Data : lines 61 to 5060 (= 5000)
Dataset Name: PiDigits
Description: This is a constructed/fabricated data set
to test accuracy in summary statistic calculations.
The numbers are the first 5000 digits of the
mathematical constant pi (= 3.1415926535897932384...).
Stat Category: Univariate
Reference: Mathematics of Computation.
January 1962, page 76.
Data: Constructed Variable
--> 1 Response : y = pi digits
--> 0 Predictors
--> 5000 Observations
Model: Lower Level of Difficulty
--> 2 Parameters : mu, sigma
--> 1 Response Variable : y
--> 0 Predictor Variables
y = mu + e
Certified Values
Sample Mean ybar: 4.53480000000000
Sample Standard Deviation (denom. = n-1) s: 2.86733906028871
Sample Autocorrelation Coefficient (lag 1) r(1): -0.00355099287237972
Number of Observations: 5000
Data: Y
---------
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9
3
2
3
8
4
6
2
6
4
3
3
8
3
2
7
9
5
0
2
8
8
4
1
9
7
1
6
9
3
9
9
3
7
5
1
0
5
8
2
0
9
7
4
9
4
4
5
9
2
3
0
7
8
1
6
4
0
6
2
8
6
2
0
8
9
9
8
6
2
8
0
3
4
8
2
5
3
4
2
1
1
7
0
6
7
9
8
2
1
4
8
0
8
6
5
1
3
2
8
2
3
0
6
6
4
7
0
9
3
8
4
4
6
0
9
5
5
0
5
8
2
2
3
1
7
2
5
3
5
9
4
0
8
1
2
8
4
8
1
1
1
7
4
5
0
2
8
4
1
0
2
7
0
1
9
3
8
5
2
1
1
0
5
5
5
9
6
4
4
6
2
2
9
4
8
9
5
4
9
3
0
3
8
1
9
6
4
4
2
8
8
1
0
9
7
5
6
6
5
9
3
3
4
4
6
1
2
8
4
7
5
6
4
8
2
3
3
7
8
6
7
8
3
1
6
5
2
7
1
2
0
1
9
0
9
1
4
5
6
4
8
5
6
6
9
2
3
4
6
0
3
4
8
6
1
0
4
5
4
3
2
6
6
4
8
2
1
3
3
9
3
6
0
7
2
6
0
2
4
9
1
4
1
2
7
3
7
2
4
5
8
7
0
0
6
6
0
6
3
1
5
5
8
8
1
7
4
8
8
1
5
2
0
9
2
0
9
6
2
8
2
9
2
5
4
0
9
1
7
1
5
3
6
4
3
6
7
8
9
2
5
9
0
3
6
0
0
1
1
3
3
0
5
3
0
5
4
8
8
2
0
4
6
6
5
2
1
3
8
4
1
4
6
9
5
1
9
4
1
5
1
1
6
0
9
4
3
3
0
5
7
2
7
0
3
6
5
7
5
9
5
9
1
9
5
3
0
9
2
1
8
6
1
1
7
3
8
1
9
3
2
6
1
1
7
9
3
1
0
5
1
1
8
5
4
8
0
7
4
4
6
2
3
7
9
9
6
2
7
4
9
5
6
7
3
5
1
8
8
5
7
5
2
7
2
4
8
9
1
2
2
7
9
3
8
1
8
3
0
1
1
9
4
9
1
2
9
8
3
3
6
7
3
3
6
2
4
4
0
6
5
6
6
4
3
0
8
6
0
2
1
3
9
4
9
4
6
3
9
5
2
2
4
7
3
7
1
9
0
7
0
2
1
7
9
8
6
0
9
4
3
7
0
2
7
7
0
5
3
9
2
1
7
1
7
6
2
9
3
1
7
6
7
5
2
3
8
4
6
7
4
8
1
8
4
6
7
6
6
9
4
0
5
1
3
2
0
0
0
5
6
8
1
2
7
1
4
5
2
6
3
5
6
0
8
2
7
7
8
5
7
7
1
3
4
2
7
5
7
7
8
9
6
0
9
1
7
3
6
3
7
1
7
8
7
2
1
4
6
8
4
4
0
9
0
1
2
2
4
9
5
3
4
3
0
1
4
6
5
4
9
5
8
5
3
7
1
0
5
0
7
9
2
2
7
9
6
8
9
2
5
8
9
2
3
5
4
2
0
1
9
9
5
6
1
1
2
1
2
9
0
2
1
9
6
0
8
6
4
0
3
4
4
1
8
1
5
9
8
1
3
6
2
9
7
7
4
7
7
1
3
0
9
9
6
0
5
1
8
7
0
7
2
1
1
3
4
9
9
9
9
9
9
8
3
7
2
9
7
8
0
4
9
9
5
1
0
5
9
7
3
1
7
3
2
8
1
6
0
9
6
3
1
8
5
9
5
0
2
4
4
5
9
4
5
5
3
4
6
9
0
8
3
0
2
6
4
2
5
2
2
3
0
8
2
5
3
3
4
4
6
8
5
0
3
5
2
6
1
9
3
1
1
8
8
1
7
1
0
1
0
0
0
3
1
3
7
8
3
8
7
5
2
8
8
6
5
8
7
5
3
3
2
0
8
3
8
1
4
2
0
6
1
7
1
7
7
6
6
9
1
4
7
3
0
3
5
9
8
2
5
3
4
9
0
4
2
8
7
5
5
4
6
8
7
3
1
1
5
9
5
6
2
8
6
3
8
8
2
3
5
3
7
8
7
5
9
3
7
5
1
9
5
7
7
8
1
8
5
7
7
3
0
5
3
2
1
7
1
2
2
6
8
0
6
6
1
3
0
0
1
9
2
7
8
7
6
6
1
1
1
9
5
9
0
9
2
1
6
4
2
0
1
9
8
9
3
8
0
9
5
2
5
7
2
0
1
0
6
5
4
8
5
8
6
3
2
7
8
8
6
5
9
3
6
1
5
3
3
8
1
8
2
7
9
6
8
2
3
0
3
0
1
9
5
2
0
3
5
3
0
1
8
5
2
9
6
8
9
9
5
7
7
3
6
2
2
5
9
9
4
1
3
8
9
1
2
4
9
7
2
1
7
7
5
2
8
3
4
7
9
1
3
1
5
1
5
5
7
4
8
5
7
2
4
2
4
5
4
1
5
0
6
9
5
9
5
0
8
2
9
5
3
3
1
1
6
8
6
1
7
2
7
8
5
5
8
8
9
0
7
5
0
9
8
3
8
1
7
5
4
6
3
7
4
6
4
9
3
9
3
1
9
2
5
5
0
6
0
4
0
0
9
2
7
7
0
1
6
7
1
1
3
9
0
0
9
8
4
8
8
2
4
0
1
2
8
5
8
3
6
1
6
0
3
5
6
3
7
0
7
6
6
0
1
0
4
7
1
0
1
8
1
9
4
2
9
5
5
5
9
6
1
9
8
9
4
6
7
6
7
8
3
7
4
4
9
4
4
8
2
5
5
3
7
9
7
7
4
7
2
6
8
4
7
1
0
4
0
4
7
5
3
4
6
4
6
2
0
8
0
4
6
6
8
4
2
5
9
0
6
9
4
9
1
2
9
3
3
1
3
6
7
7
0
2
8
9
8
9
1
5
2
1
0
4
7
5
2
1
6
2
0
5
6
9
6
6
0
2
4
0
5
8
0
3
8
1
5
0
1
9
3
5
1
1
2
5
3
3
8
2
4
3
0
0
3
5
5
8
7
6
4
0
2
4
7
4
9
6
4
7
3
2
6
3
9
1
4
1
9
9
2
7
2
6
0
4
2
6
9
9
2
2
7
9
6
7
8
2
3
5
4
7
8
1
6
3
6
0
0
9
3
4
1
7
2
1
6
4
1
2
1
9
9
2
4
5
8
6
3
1
5
0
3
0
2
8
6
1
8
2
9
7
4
5
5
5
7
0
6
7
4
9
8
3
8
5
0
5
4
9
4
5
8
8
5
8
6
9
2
6
9
9
5
6
9
0
9
2
7
2
1
0
7
9
7
5
0
9
3
0
2
9
5
5
3
2
1
1
6
5
3
4
4
9
8
7
2
0
2
7
5
5
9
6
0
2
3
6
4
8
0
6
6
5
4
9
9
1
1
9
8
8
1
8
3
4
7
9
7
7
5
3
5
6
6
3
6
9
8
0
7
4
2
6
5
4
2
5
2
7
8
6
2
5
5
1
8
1
8
4
1
7
5
7
4
6
7
2
8
9
0
9
7
7
7
7
2
7
9
3
8
0
0
0
8
1
6
4
7
0
6
0
0
1
6
1
4
5
2
4
9
1
9
2
1
7
3
2
1
7
2
1
4
7
7
2
3
5
0
1
4
1
4
4
1
9
7
3
5
6
8
5
4
8
1
6
1
3
6
1
1
5
7
3
5
2
5
5
2
1
3
3
4
7
5
7
4
1
8
4
9
4
6
8
4
3
8
5
2
3
3
2
3
9
0
7
3
9
4
1
4
3
3
3
4
5
4
7
7
6
2
4
1
6
8
6
2
5
1
8
9
8
3
5
6
9
4
8
5
5
6
2
0
9
9
2
1
9
2
2
2
1
8
4
2
7
2
5
5
0
2
5
4
2
5
6
8
8
7
6
7
1
7
9
0
4
9
4
6
0
1
6
5
3
4
6
6
8
0
4
9
8
8
6
2
7
2
3
2
7
9
1
7
8
6
0
8
5
7
8
4
3
8
3
8
2
7
9
6
7
9
7
6
6
8
1
4
5
4
1
0
0
9
5
3
8
8
3
7
8
6
3
6
0
9
5
0
6
8
0
0
6
4
2
2
5
1
2
5
2
0
5
1
1
7
3
9
2
9
8
4
8
9
6
0
8
4
1
2
8
4
8
8
6
2
6
9
4
5
6
0
4
2
4
1
9
6
5
2
8
5
0
2
2
2
1
0
6
6
1
1
8
6
3
0
6
7
4
4
2
7
8
6
2
2
0
3
9
1
9
4
9
4
5
0
4
7
1
2
3
7
1
3
7
8
6
9
6
0
9
5
6
3
6
4
3
7
1
9
1
7
2
8
7
4
6
7
7
6
4
6
5
7
5
7
3
9
6
2
4
1
3
8
9
0
8
6
5
8
3
2
6
4
5
9
9
5
8
1
3
3
9
0
4
7
8
0
2
7
5
9
0
0
9
9
4
6
5
7
6
4
0
7
8
9
5
1
2
6
9
4
6
8
3
9
8
3
5
2
5
9
5
7
0
9
8
2
5
8
2
2
6
2
0
5
2
2
4
8
9
4
0
7
7
2
6
7
1
9
4
7
8
2
6
8
4
8
2
6
0
1
4
7
6
9
9
0
9
0
2
6
4
0
1
3
6
3
9
4
4
3
7
4
5
5
3
0
5
0
6
8
2
0
3
4
9
6
2
5
2
4
5
1
7
4
9
3
9
9
6
5
1
4
3
1
4
2
9
8
0
9
1
9
0
6
5
9
2
5
0
9
3
7
2
2
1
6
9
6
4
6
1
5
1
5
7
0
9
8
5
8
3
8
7
4
1
0
5
9
7
8
8
5
9
5
9
7
7
2
9
7
5
4
9
8
9
3
0
1
6
1
7
5
3
9
2
8
4
6
8
1
3
8
2
6
8
6
8
3
8
6
8
9
4
2
7
7
4
1
5
5
9
9
1
8
5
5
9
2
5
2
4
5
9
5
3
9
5
9
4
3
1
0
4
9
9
7
2
5
2
4
6
8
0
8
4
5
9
8
7
2
7
3
6
4
4
6
9
5
8
4
8
6
5
3
8
3
6
7
3
6
2
2
2
6
2
6
0
9
9
1
2
4
6
0
8
0
5
1
2
4
3
8
8
4
3
9
0
4
5
1
2
4
4
1
3
6
5
4
9
7
6
2
7
8
0
7
9
7
7
1
5
6
9
1
4
3
5
9
9
7
7
0
0
1
2
9
6
1
6
0
8
9
4
4
1
6
9
4
8
6
8
5
5
5
8
4
8
4
0
6
3
5
3
4
2
2
0
7
2
2
2
5
8
2
8
4
8
8
6
4
8
1
5
8
4
5
6
0
2
8
5
0
6
0
1
6
8
4
2
7
3
9
4
5
2
2
6
7
4
6
7
6
7
8
8
9
5
2
5
2
1
3
8
5
2
2
5
4
9
9
5
4
6
6
6
7
2
7
8
2
3
9
8
6
4
5
6
5
9
6
1
1
6
3
5
4
8
8
6
2
3
0
5
7
7
4
5
6
4
9
8
0
3
5
5
9
3
6
3
4
5
6
8
1
7
4
3
2
4
1
1
2
5
1
5
0
7
6
0
6
9
4
7
9
4
5
1
0
9
6
5
9
6
0
9
4
0
2
5
2
2
8
8
7
9
7
1
0
8
9
3
1
4
5
6
6
9
1
3
6
8
6
7
2
2
8
7
4
8
9
4
0
5
6
0
1
0
1
5
0
3
3
0
8
6
1
7
9
2
8
6
8
0
9
2
0
8
7
4
7
6
0
9
1
7
8
2
4
9
3
8
5
8
9
0
0
9
7
1
4
9
0
9
6
7
5
9
8
5
2
6
1
3
6
5
5
4
9
7
8
1
8
9
3
1
2
9
7
8
4
8
2
1
6
8
2
9
9
8
9
4
8
7
2
2
6
5
8
8
0
4
8
5
7
5
6
4
0
1
4
2
7
0
4
7
7
5
5
5
1
3
2
3
7
9
6
4
1
4
5
1
5
2
3
7
4
6
2
3
4
3
6
4
5
4
2
8
5
8
4
4
4
7
9
5
2
6
5
8
6
7
8
2
1
0
5
1
1
4
1
3
5
4
7
3
5
7
3
9
5
2
3
1
1
3
4
2
7
1
6
6
1
0
2
1
3
5
9
6
9
5
3
6
2
3
1
4
4
2
9
5
2
4
8
4
9
3
7
1
8
7
1
1
0
1
4
5
7
6
5
4
0
3
5
9
0
2
7
9
9
3
4
4
0
3
7
4
2
0
0
7
3
1
0
5
7
8
5
3
9
0
6
2
1
9
8
3
8
7
4
4
7
8
0
8
4
7
8
4
8
9
6
8
3
3
2
1
4
4
5
7
1
3
8
6
8
7
5
1
9
4
3
5
0
6
4
3
0
2
1
8
4
5
3
1
9
1
0
4
8
4
8
1
0
0
5
3
7
0
6
1
4
6
8
0
6
7
4
9
1
9
2
7
8
1
9
1
1
9
7
9
3
9
9
5
2
0
6
1
4
1
9
6
6
3
4
2
8
7
5
4
4
4
0
6
4
3
7
4
5
1
2
3
7
1
8
1
9
2
1
7
9
9
9
8
3
9
1
0
1
5
9
1
9
5
6
1
8
1
4
6
7
5
1
4
2
6
9
1
2
3
9
7
4
8
9
4
0
9
0
7
1
8
6
4
9
4
2
3
1
9
6
1
5
6
7
9
4
5
2
0
8
0
9
5
1
4
6
5
5
0
2
2
5
2
3
1
6
0
3
8
8
1
9
3
0
1
4
2
0
9
3
7
6
2
1
3
7
8
5
5
9
5
6
6
3
8
9
3
7
7
8
7
0
8
3
0
3
9
0
6
9
7
9
2
0
7
7
3
4
6
7
2
2
1
8
2
5
6
2
5
9
9
6
6
1
5
0
1
4
2
1
5
0
3
0
6
8
0
3
8
4
4
7
7
3
4
5
4
9
2
0
2
6
0
5
4
1
4
6
6
5
9
2
5
2
0
1
4
9
7
4
4
2
8
5
0
7
3
2
5
1
8
6
6
6
0
0
2
1
3
2
4
3
4
0
8
8
1
9
0
7
1
0
4
8
6
3
3
1
7
3
4
6
4
9
6
5
1
4
5
3
9
0
5
7
9
6
2
6
8
5
6
1
0
0
5
5
0
8
1
0
6
6
5
8
7
9
6
9
9
8
1
6
3
5
7
4
7
3
6
3
8
4
0
5
2
5
7
1
4
5
9
1
0
2
8
9
7
0
6
4
1
4
0
1
1
0
9
7
1
2
0
6
2
8
0
4
3
9
0
3
9
7
5
9
5
1
5
6
7
7
1
5
7
7
0
0
4
2
0
3
3
7
8
6
9
9
3
6
0
0
7
2
3
0
5
5
8
7
6
3
1
7
6
3
5
9
4
2
1
8
7
3
1
2
5
1
4
7
1
2
0
5
3
2
9
2
8
1
9
1
8
2
6
1
8
6
1
2
5
8
6
7
3
2
1
5
7
9
1
9
8
4
1
4
8
4
8
8
2
9
1
6
4
4
7
0
6
0
9
5
7
5
2
7
0
6
9
5
7
2
2
0
9
1
7
5
6
7
1
1
6
7
2
2
9
1
0
9
8
1
6
9
0
9
1
5
2
8
0
1
7
3
5
0
6
7
1
2
7
4
8
5
8
3
2
2
2
8
7
1
8
3
5
2
0
9
3
5
3
9
6
5
7
2
5
1
2
1
0
8
3
5
7
9
1
5
1
3
6
9
8
8
2
0
9
1
4
4
4
2
1
0
0
6
7
5
1
0
3
3
4
6
7
1
1
0
3
1
4
1
2
6
7
1
1
1
3
6
9
9
0
8
6
5
8
5
1
6
3
9
8
3
1
5
0
1
9
7
0
1
6
5
1
5
1
1
6
8
5
1
7
1
4
3
7
6
5
7
6
1
8
3
5
1
5
5
6
5
0
8
8
4
9
0
9
9
8
9
8
5
9
9
8
2
3
8
7
3
4
5
5
2
8
3
3
1
6
3
5
5
0
7
6
4
7
9
1
8
5
3
5
8
9
3
2
2
6
1
8
5
4
8
9
6
3
2
1
3
2
9
3
3
0
8
9
8
5
7
0
6
4
2
0
4
6
7
5
2
5
9
0
7
0
9
1
5
4
8
1
4
1
6
5
4
9
8
5
9
4
6
1
6
3
7
1
8
0
2
7
0
9
8
1
9
9
4
3
0
9
9
2
4
4
8
8
9
5
7
5
7
1
2
8
2
8
9
0
5
9
2
3
2
3
3
2
6
0
9
7
2
9
9
7
1
2
0
8
4
4
3
3
5
7
3
2
6
5
4
8
9
3
8
2
3
9
1
1
9
3
2
5
9
7
4
6
3
6
6
7
3
0
5
8
3
6
0
4
1
4
2
8
1
3
8
8
3
0
3
2
0
3
8
2
4
9
0
3
7
5
8
9
8
5
2
4
3
7
4
4
1
7
0
2
9
1
3
2
7
6
5
6
1
8
0
9
3
7
7
3
4
4
4
0
3
0
7
0
7
4
6
9
2
1
1
2
0
1
9
1
3
0
2
0
3
3
0
3
8
0
1
9
7
6
2
1
1
0
1
1
0
0
4
4
9
2
9
3
2
1
5
1
6
0
8
4
2
4
4
4
8
5
9
6
3
7
6
6
9
8
3
8
9
5
2
2
8
6
8
4
7
8
3
1
2
3
5
5
2
6
5
8
2
1
3
1
4
4
9
5
7
6
8
5
7
2
6
2
4
3
3
4
4
1
8
9
3
0
3
9
6
8
6
4
2
6
2
4
3
4
1
0
7
7
3
2
2
6
9
7
8
0
2
8
0
7
3
1
8
9
1
5
4
4
1
1
0
1
0
4
4
6
8
2
3
2
5
2
7
1
6
2
0
1
0
5
2
6
5
2
2
7
2
1
1
1
6
6
0
3
9
6
6
6
5
5
7
3
0
9
2
5
4
7
1
1
0
5
5
7
8
5
3
7
6
3
4
6
6
8
2
0
6
5
3
1
0
9
8
9
6
5
2
6
9
1
8
6
2
0
5
6
4
7
6
9
3
1
2
5
7
0
5
8
6
3
5
6
6
2
0
1
8
5
5
8
1
0
0
7
2
9
3
6
0
6
5
9
8
7
6
4
8
6
1
1
7
9
1
0
4
5
3
3
4
8
8
5
0
3
4
6
1
1
3
6
5
7
6
8
6
7
5
3
2
4
9
4
4
1
6
6
8
0
3
9
6
2
6
5
7
9
7
8
7
7
1
8
5
5
6
0
8
4
5
5
2
9
6
5
4
1
2
6
6
5
4
0
8
5
3
0
6
1
4
3
4
4
4
3
1
8
5
8
6
7
6
9
7
5
1
4
5
6
6
1
4
0
6
8
0
0
7
0
0
2
3
7
8
7
7
6
5
9
1
3
4
4
0
1
7
1
2
7
4
9
4
7
0
4
2
0
5
6
2
2
3
0
5
3
8
9
9
4
5
6
1
3
1
4
0
7
1
1
2
7
0
0
0
4
0
7
8
5
4
7
3
3
2
6
9
9
3
9
0
8
1
4
5
4
6
6
4
6
4
5
8
8
0
7
9
7
2
7
0
8
2
6
6
8
3
0
6
3
4
3
2
8
5
8
7
8
5
6
9
8
3
0
5
2
3
5
8
0
8
9
3
3
0
6
5
7
5
7
4
0
6
7
9
5
4
5
7
1
6
3
7
7
5
2
5
4
2
0
2
1
1
4
9
5
5
7
6
1
5
8
1
4
0
0
2
5
0
1
2
6
2
2
8
5
9
4
1
3
0
2
1
6
4
7
1
5
5
0
9
7
9
2
5
9
2
3
0
9
9
0
7
9
6
5
4
7
3
7
6
1
2
5
5
1
7
6
5
6
7
5
1
3
5
7
5
1
7
8
2
9
6
6
6
4
5
4
7
7
9
1
7
4
5
0
1
1
2
9
9
6
1
4
8
9
0
3
0
4
6
3
9
9
4
7
1
3
2
9
6
2
1
0
7
3
4
0
4
3
7
5
1
8
9
5
7
3
5
9
6
1
4
5
8
9
0
1
9
3
8
9
7
1
3
1
1
1
7
9
0
4
2
9
7
8
2
8
5
6
4
7
5
0
3
2
0
3
1
9
8
6
9
1
5
1
4
0
2
8
7
0
8
0
8
5
9
9
0
4
8
0
1
0
9
4
1
2
1
4
7
2
2
1
3
1
7
9
4
7
6
4
7
7
7
2
6
2
2
4
1
4
2
5
4
8
5
4
5
4
0
3
3
2
1
5
7
1
8
5
3
0
6
1
4
2
2
8
8
1
3
7
5
8
5
0
4
3
0
6
3
3
2
1
7
5
1
8
2
9
7
9
8
6
6
2
2
3
7
1
7
2
1
5
9
1
6
0
7
7
1
6
6
9
2
5
4
7
4
8
7
3
8
9
8
6
6
5
4
9
4
9
4
5
0
1
1
4
6
5
4
0
6
2
8
4
3
3
6
6
3
9
3
7
9
0
0
3
9
7
6
9
2
6
5
6
7
2
1
4
6
3
8
5
3
0
6
7
3
6
0
9
6
5
7
1
2
0
9
1
8
0
7
6
3
8
3
2
7
1
6
6
4
1
6
2
7
4
8
8
8
8
0
0
7
8
6
9
2
5
6
0
2
9
0
2
2
8
4
7
2
1
0
4
0
3
1
7
2
1
1
8
6
0
8
2
0
4
1
9
0
0
0
4
2
2
9
6
6
1
7
1
1
9
6
3
7
7
9
2
1
3
3
7
5
7
5
1
1
4
9
5
9
5
0
1
5
6
6
0
4
9
6
3
1
8
6
2
9
4
7
2
6
5
4
7
3
6
4
2
5
2
3
0
8
1
7
7
0
3
6
7
5
1
5
9
0
6
7
3
5
0
2
3
5
0
7
2
8
3
5
4
0
5
6
7
0
4
0
3
8
6
7
4
3
5
1
3
6
2
2
2
2
4
7
7
1
5
8
9
1
5
0
4
9
5
3
0
9
8
4
4
4
8
9
3
3
3
0
9
6
3
4
0
8
7
8
0
7
6
9
3
2
5
9
9
3
9
7
8
0
5
4
1
9
3
4
1
4
4
7
3
7
7
4
4
1
8
4
2
6
3
1
2
9
8
6
0
8
0
9
9
8
8
8
6
8
7
4
1
3
2
6
0
4
7
2
commons-math-2.2-src/src/test/resources/org/apache/commons/math/stat/data/Mavro.txt 100644 1750 1750 4035 11532241244 27202 0 ustar luc luc 0 0 File Name: Mavro.dat
File Format: ASCII
Header : lines 1 to 60 (= 60)
Certified Values: lines 41 to 43 (= 3)
Data : lines 61 to 110 (= 50)
Dataset Name: Mavro (Filter Transmittance Data)
Description: This is an observed/"real world" data set
consisting of 50 transmittance measurements
(at a sampling rate of 10 observations per second)
from a filter with a nominal value of 2.
The experimenter was Radu Mavrodineaunu,
a member of the chemistry staff at NIST.
We here use this data to test accuracy
in summary statistics calculations.
Stat Category: Univariate: Summary Statistics
Reference: None
Data: "Real World"
1 Response : y = transmittance
0 Predictors
50 Observations
Model: Lower Level of Difficulty
2 Parameters : mu, sigma
1 Response Variable : y
0 Predictor Variables
y = mu + e
Certified Values
Sample Mean ybar: 2.00185600000000
Sample Standard Deviation (denom. = n-1) s: 0.000429123454003053
Sample Autocorrelation Coefficient (lag 1) r(1): 0.937989183438248
Number of Observations: 50
Data: Y
-------------
2.00180
2.00170
2.00180
2.00190
2.00180
2.00170
2.00150
2.00140
2.00150
2.00150
2.00170
2.00180
2.00180
2.00190
2.00190
2.00210
2.00200
2.00160
2.00140
2.00130
2.00130
2.00150
2.00150
2.00160
2.00150
2.00140
2.00130
2.00140
2.00150
2.00140
2.00150
2.00160
2.00150
2.00160
2.00190
2.00200
2.00200
2.00210
2.00220
2.00230
2.00240
2.00250
2.00270
2.00260
2.00260
2.00260
2.00270
2.00260
2.00250
2.00240
commons-math-2.2-src/src/test/resources/org/apache/commons/math/stat/data/Lottery.txt 100644 1750 1750 6777 11532241244 27577 0 ustar luc luc 0 0 #####################################################################
# Dataset Name: Lottery
#
#Description: This is an observed/"real world" data set
# consisting of 218 lottery values
# from September 3, 1989 to April 14, 1990 (32 weeks).
# One 3-digit random number (from 000 to 999)
# is drawn per day, 7 days per week for most
# weeks, but fewer days per week for some weeks.
# We here use this data to test accuracy
# in summary statistics calculations.
#
# Stat Category: Univariate: Summary Statistics
#
# Reference: http://www.itl.nist.gov/div898/strd/univ/lottery.html
#
# Data: "Real World"
# 1 Response : y = 3-digit random number
# 0 Predictors
# 218 Observations
#
# Model: Lower Level of Difficulty
# 2 Parameters : mu, sigma
# 1 Response Variable : y
# 0 Predictor Variables#
# y = mu + e
#####################################################################
#####################################################################
#
# Certified Values
#
#####################################################################
mean = 518.958715596330
standardDeviation = 291.699727470969
autocorrelationCoefficient = -0.120948622967393
n = 218
#####################################################################
#
# Data
#
#####################################################################
162
671
933
414
788
730
817
33
536
875
670
236
473
167
877
980
316
950
456
92
517
557
956
954
104
178
794
278
147
773
437
435
502
610
582
780
689
562
964
791
28
97
848
281
858
538
660
972
671
613
867
448
738
966
139
636
847
659
754
243
122
455
195
968
793
59
730
361
574
522
97
762
431
158
429
414
22
629
788
999
187
215
810
782
47
34
108
986
25
644
829
630
315
567
919
331
207
412
242
607
668
944
749
168
864
442
533
805
372
63
458
777
416
340
436
140
919
350
510
572
905
900
85
389
473
758
444
169
625
692
140
897
672
288
312
860
724
226
884
508
976
741
476
417
831
15
318
432
241
114
799
955
833
358
935
146
630
830
440
642
356
373
271
715
367
393
190
669
8
861
108
795
269
590
326
866
64
523
862
840
219
382
998
4
628
305
747
247
34
747
729
645
856
974
24
568
24
694
608
480
410
729
947
293
53
930
223
203
677
227
62
455
387
318
562
242
428
968
commons-math-2.2-src/src/test/resources/org/apache/commons/math/stat/data/NumAcc1.txt 100644 1750 1750 3334 11532241244 27346 0 ustar luc luc 0 0 File Name: NumAcc1.dat
File Format: ASCII
Header : lines 1 to 60 (= 60)
Certified Values: lines 41 to 43 (= 3)
Data : lines 61 to 63 (= 3)
Dataset Name: NumAcc1
Description: This is a constructed/fabricated data set
to test accuracy in summary statistic calculations.
The numbers are large (8-digit integers) and
differ only in the last decimal place.
Note--by construction, this data set has
sample mean = 10000002 (exact)
sample standard deviation = 1 (exact)
sample autocorrelation coef. = -0.5 (exact)
Stat Category: Univariate: Summary Statistics
Reference: Simon, Stephen D. and Lesage, James P. (1989).
Assessing the Accuracy of ANOVA Caluclations
in Statistical Software", Computational
Statistics & data Analysis, 8, pp. 325-332.
Data: Constructed
1 Response : y
0 Predictors
3 Observations
Model: Lower Level of Difficulty
2 Parameters : mu, sigma
1 Response Variable : y
0 Predictor Variables
y = mu + e
Certified Values
Sample Mean ybar: 10000002
Sample Standard Deviation (denom. = n-1) s: 1
Sample Autocorrelation Coefficient (lag 1) r(1): -0.5
Number of Observations: 3
Data: Y
---------
10000001
10000003
10000002
commons-math-2.2-src/src/test/resources/org/apache/commons/math/stat/data/Michelso.txt 100644 1750 1750 4215 11532241244 27661 0 ustar luc luc 0 0 File Name: Michelso.dat
File Format: ASCII
Header : lines 1 to 60 (= 60)
Certified Values: lines 41 to 43 (= 3)
Data : lines 61 to 160 (= 100)
Dataset Name: Michelso (Speed of Light Data, in millions of meters per second)
Description: This is an observed/"real world" data set
consisting of 100 measurements of the
speed of light in air. This classic experiment
was carried out by Michelson is 1879.
We here use this data to test accuracy
in summary statistics calculations.
Stat Category: Univariate: Summary Statistics
Reference: Dorsey, Ernest N. (1944). The Velocity of Light.
Transactions of the American Philiosophical
Society, Volume 34, Part 1, Pages 1-110, Table 22.
y = mu + e
Certified Values
Sample Mean ybar: 299.852400000000
Sample Standard Deviation (denom. = n-1) s: 0.0790105478190518
Sample Autocorrelation Coefficient (lag 1) r(1): 0.535199668621283
Number of Observations: 100
Data: Y
----------
299.85
299.74
299.90
300.07
299.93
299.85
299.95
299.98
299.98
299.88
300.00
299.98
299.93
299.65
299.76
299.81
300.00
300.00
299.96
299.96
299.96
299.94
299.96
299.94
299.88
299.80
299.85
299.88
299.90
299.84
299.83
299.79
299.81
299.88
299.88
299.83
299.80
299.79
299.76
299.80
299.88
299.88
299.88
299.86
299.72
299.72
299.62
299.86
299.97
299.95
299.88
299.91
299.85
299.87
299.84
299.84
299.85
299.84
299.84
299.84
299.89
299.81
299.81
299.82
299.80
299.77
299.76
299.74
299.75
299.76
299.91
299.92
299.89
299.86
299.88
299.72
299.84
299.85
299.85
299.78
299.89
299.84
299.78
299.81
299.76
299.81
299.79
299.81
299.82
299.85
299.87
299.87
299.81
299.74
299.81
299.94
299.95
299.80
299.81
299.87
commons-math-2.2-src/src/test/resources/org/apache/commons/math/stat/data/NumAcc4.txt 100644 1750 1750 34533 11532241244 27376 0 ustar luc luc 0 0 File Name: NumAcc4.dat
File Format: ASCII
Header : lines 1 to 60 (= 60)
Certified Values: lines 41 to 43 (= 3)
Data : lines 61 to 1061 (= 1001)
Dataset Name: NumAcc4
Description: This is a constructed/fabricated data set
to test accuracy in summary statistic calculations.
The numbers are 9-digit floating point values and
differ only in the last decimal place.
sample mean = 10000000.2 (exact)
sample standard dev. = 0.1 (exact)
sample autocorr. coef. = -0.999 (exact)
Stat Category: Univariate
Reference: Simon, Stephen D. and Lesage, James P. (1989).
Assessing the Accuracy of ANOVA Caluclations
in Statistical Software", Computational
Statistics & data Analysis, 8, pp. 325-332.
Data: Constructed
1 Response : y
0 Predictors
1001 Observations
Model: Higher Level of Difficulty
2 Parameters : mu, sigma
1 Response Variable : y
0 Predictor Variables
y = mu + e
Certified Values
Sample Mean ybar: 10000000.2
Sample Standard Deviation (denom. = n-1) s: 0.1
Sample Autocorrelation Coefficient (lag 1) r(1): -0.999
Number of Observations: 1001
Data: Y
--------------
10000000.2
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
10000000.1
10000000.3
commons-math-2.2-src/src/test/resources/org/apache/commons/math/stat/data/NumAcc2.txt 100644 1750 1750 24727 11532241244 27400 0 ustar luc luc 0 0 File Name: NumAcc2.dat
File Format: ASCII
Header : lines 1 to 60 (= 60)
Certified Values: lines 41 to 43 (= 3)
Data : lines 61 to 1061 (= 1001)
Dataset Name: NumAcc2
Description: This is a constructed/fabricated data set
to test accuracy in summary statistic calculations.
The numbers are 2-digit floating point values and
differ only in the last decimal place.
Note--by construction, this data set has
sample mean = 1.2 (exact)
sample standard deviation = 0.1 (exact)
sample autocorrelation coef. = -0.999 (exact)
Stat Category: Univariate
Reference: Simon, Stephen D. and Lesage, James P. (1989).
Assessing the Accuracy of ANOVA Caluclations
in Statistical Software", Computational
Statistics & data Analysis, 8, pp. 325-332.
Data: Constructed
1 Response : y
0 Predictors
1001 Observations
Model: Average Level of Difficulty
2 Parameters : mu, sigma
1 Response Variable : y
0 Predictor Variables
y = mu + e
Certified Values
Sample Mean ybar: 1.2
Sample Standard Deviation (denom. = n-1) s: 0.1
Sample Autocorrelation Coefficient (lag 1) r(1): -0.999
Number of Observations: 1001
Data: Y
---------
1.2
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
1.1
1.3
commons-math-2.2-src/src/test/java/org/apache/commons/math/MathExceptionTest.java 100644 1750 1750 13243 11532241244 26674 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math;
import junit.framework.TestCase;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Locale;
import org.apache.commons.math.exception.util.DummyLocalizable;
import org.apache.commons.math.exception.util.Localizable;
import org.apache.commons.math.exception.util.LocalizedFormats;
/**
* @version $Revision: 1035475 $ $Date: 2010-11-15 23:39:25 +0100 (lun. 15 nov. 2010) $
*/
public class MathExceptionTest extends TestCase {
public void testConstructor(){
MathException ex = new MathException();
assertNull(ex.getCause());
assertEquals("", ex.getMessage());
assertEquals("", ex.getMessage(Locale.FRENCH));
}
public void testConstructorPatternArguments(){
LocalizedFormats pattern = LocalizedFormats.ROTATION_MATRIX_DIMENSIONS;
Object[] arguments = { Integer.valueOf(6), Integer.valueOf(4) };
MathException ex = new MathException(pattern, arguments);
assertNull(ex.getCause());
assertEquals(pattern, ex.getGeneralPattern());
assertEquals(arguments.length, ex.getArguments().length);
for (int i = 0; i < arguments.length; ++i) {
assertEquals(arguments[i], ex.getArguments()[i]);
}
assertFalse(pattern.equals(ex.getMessage()));
assertFalse(ex.getMessage().equals(ex.getMessage(Locale.FRENCH)));
}
public void testConstructorCause(){
String inMsg = "inner message";
Exception cause = new Exception(inMsg);
MathException ex = new MathException(cause);
assertEquals(cause, ex.getCause());
}
public void testConstructorPatternArgumentsCause(){
LocalizedFormats pattern = LocalizedFormats.ROTATION_MATRIX_DIMENSIONS;
Object[] arguments = { Integer.valueOf(6), Integer.valueOf(4) };
String inMsg = "inner message";
Exception cause = new Exception(inMsg);
MathException ex = new MathException(cause, pattern, arguments);
assertEquals(cause, ex.getCause());
assertEquals(pattern, ex.getGeneralPattern());
assertEquals(arguments.length, ex.getArguments().length);
for (int i = 0; i < arguments.length; ++i) {
assertEquals(arguments[i], ex.getArguments()[i]);
}
assertFalse(pattern.equals(ex.getMessage()));
assertFalse(ex.getMessage().equals(ex.getMessage(Locale.FRENCH)));
}
/**
* Tests the printStackTrace() operation.
*/
public void testPrintStackTrace() {
Localizable outMsg = new DummyLocalizable("outer message");
Localizable inMsg = new DummyLocalizable("inner message");
MathException cause = new MathConfigurationException(inMsg);
MathException ex = new MathException(cause, outMsg);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
ex.printStackTrace(ps);
String stack = baos.toString();
String outerMsg = "org.apache.commons.math.MathException: outer message";
String innerMsg = "Caused by: " +
"org.apache.commons.math.MathConfigurationException: inner message";
assertTrue(stack.startsWith(outerMsg));
assertTrue(stack.indexOf(innerMsg) > 0);
PrintWriter pw = new PrintWriter(ps, true);
ex.printStackTrace(pw);
stack = baos.toString();
assertTrue(stack.startsWith(outerMsg));
assertTrue(stack.indexOf(innerMsg) > 0);
}
/**
* Test serialization
*/
public void testSerialization() {
Localizable outMsg = new DummyLocalizable("outer message");
Localizable inMsg = new DummyLocalizable("inner message");
MathException cause = new MathConfigurationException(inMsg);
MathException ex = new MathException(cause, outMsg);
MathException image = (MathException) TestUtils.serializeAndRecover(ex);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
ex.printStackTrace(ps);
String stack = baos.toString();
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
PrintStream ps2 = new PrintStream(baos2);
image.printStackTrace(ps2);
String stack2 = baos2.toString();
// See if JDK supports nested exceptions. If not, stack trace of
// inner exception will not be serialized
boolean jdkSupportsNesting = false;
try {
Throwable.class.getDeclaredMethod("getCause", new Class[0]);
jdkSupportsNesting = true;
} catch (NoSuchMethodException e) {
jdkSupportsNesting = false;
}
if (jdkSupportsNesting) {
assertEquals(stack, stack2);
} else {
assertTrue(stack2.indexOf(inMsg.getSourceString()) != -1);
assertTrue(stack2.indexOf("MathConfigurationException") != -1);
}
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/estimation/WeightedMeasurementTest.java 100644 1750 1750 7020 11532241243 32221 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.estimation;
import org.apache.commons.math.estimation.EstimatedParameter;
import org.apache.commons.math.estimation.WeightedMeasurement;
import org.apache.commons.math.util.FastMath;
import junit.framework.*;
@Deprecated
public class WeightedMeasurementTest
extends TestCase {
public WeightedMeasurementTest(String name) {
super(name);
p1 = null;
p2 = null;
}
public void testConstruction() {
WeightedMeasurement m = new MyMeasurement(3.0, theoretical() + 0.1, this);
checkValue(m.getWeight(), 3.0);
checkValue(m.getMeasuredValue(), theoretical() + 0.1);
}
public void testIgnored() {
WeightedMeasurement m = new MyMeasurement(3.0, theoretical() + 0.1, this);
assertTrue(!m.isIgnored());
m.setIgnored(true);
assertTrue(m.isIgnored());
m.setIgnored(false);
assertTrue(!m.isIgnored());
}
public void testTheory() {
WeightedMeasurement m = new MyMeasurement(3.0, theoretical() + 0.1, this);
checkValue(m.getTheoreticalValue(), theoretical());
checkValue(m.getResidual(), 0.1);
double oldP1 = p1.getEstimate();
p1.setEstimate(oldP1 + m.getResidual() / m.getPartial(p1));
checkValue(m.getResidual(), 0.0);
p1.setEstimate(oldP1);
checkValue(m.getResidual(), 0.1);
double oldP2 = p2.getEstimate();
p2.setEstimate(oldP2 + m.getResidual() / m.getPartial(p2));
checkValue(m.getResidual(), 0.0);
p2.setEstimate(oldP2);
checkValue(m.getResidual(), 0.1);
}
@Override
public void setUp() {
p1 = new EstimatedParameter("p1", 1.0);
p2 = new EstimatedParameter("p2", 2.0);
}
@Override
public void tearDown() {
p1 = null;
p2 = null;
}
private void checkValue(double value, double expected) {
assertTrue(FastMath.abs(value - expected) < 1.0e-10);
}
private double theoretical() {
return 3 * p1.getEstimate() - p2.getEstimate();
}
private double partial(EstimatedParameter p) {
if (p == p1) {
return 3.0;
} else if (p == p2) {
return -1.0;
} else {
return 0.0;
}
}
private static class MyMeasurement
extends WeightedMeasurement {
public MyMeasurement(double weight, double measuredValue,
WeightedMeasurementTest testInstance) {
super(weight, measuredValue);
this.testInstance = testInstance;
}
@Override
public double getTheoreticalValue() {
return testInstance.theoretical();
}
@Override
public double getPartial(EstimatedParameter p) {
return testInstance.partial(p);
}
private transient WeightedMeasurementTest testInstance;
private static final long serialVersionUID = -246712922500792332L;
}
private EstimatedParameter p1;
private EstimatedParameter p2;
}
././@LongLink 100644 0 0 153 11532242443 10252 L ustar 0 0 commons-math-2.2-src/src/test/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java commons-math-2.2-src/src/test/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTes100644 1750 1750 101346 11532241243 32677 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.estimation;
import java.util.ArrayList;
import java.util.HashSet;
import org.apache.commons.math.util.FastMath;
import junit.framework.TestCase;
/**
* Some of the unit tests are re-implementations of the MINPACK file17 and file22 test files.
* The redistribution policy for MINPACK is available here, for
* convenience, it is reproduced below.
*
*
* Minpack Copyright Notice (1999) University of Chicago.
* All rights reserved
* |
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* - The end-user documentation included with the redistribution, if any,
* must include the following acknowledgment:
*
This product includes software developed by the University of
* Chicago, as Operator of Argonne National Laboratory.
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* - WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS"
* WITHOUT WARRANTY OF ANY KIND. THE COPYRIGHT HOLDER, THE
* UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND
* THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE
* OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY
* OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR
* USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF
* THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4)
* DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION
* UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL
* BE CORRECTED.
* - LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT
* HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF
* ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT,
* INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF
* ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF
* PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER
* SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT
* (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE,
* EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE
* POSSIBILITY OF SUCH LOSS OR DAMAGES.
*
|
*
* @author Argonne National Laboratory. MINPACK project. March 1980 (original fortran minpack tests)
* @author Burton S. Garbow (original fortran minpack tests)
* @author Kenneth E. Hillstrom (original fortran minpack tests)
* @author Jorge J. More (original fortran minpack tests)
* @author Luc Maisonobe (non-minpack tests and minpack tests Java translation)
*/
@Deprecated
public class LevenbergMarquardtEstimatorTest
extends TestCase {
public LevenbergMarquardtEstimatorTest(String name) {
super(name);
}
public void testTrivial() throws EstimationException {
LinearProblem problem =
new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] {2},
new EstimatedParameter[] {
new EstimatedParameter("p0", 0)
}, 3.0)
});
LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
estimator.estimate(problem);
assertEquals(0, estimator.getRMS(problem), 1.0e-10);
try {
estimator.guessParametersErrors(problem);
fail("an exception should have been thrown");
} catch (EstimationException ee) {
// expected behavior
}
assertEquals(1.5,
problem.getUnboundParameters()[0].getEstimate(),
1.0e-10);
}
public void testQRColumnsPermutation() throws EstimationException {
EstimatedParameter[] x = {
new EstimatedParameter("p0", 0), new EstimatedParameter("p1", 0)
};
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 1.0, -1.0 },
new EstimatedParameter[] { x[0], x[1] },
4.0),
new LinearMeasurement(new double[] { 2.0 },
new EstimatedParameter[] { x[1] },
6.0),
new LinearMeasurement(new double[] { 1.0, -2.0 },
new EstimatedParameter[] { x[0], x[1] },
1.0)
});
LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
estimator.estimate(problem);
assertEquals(0, estimator.getRMS(problem), 1.0e-10);
assertEquals(7.0, x[0].getEstimate(), 1.0e-10);
assertEquals(3.0, x[1].getEstimate(), 1.0e-10);
}
public void testNoDependency() throws EstimationException {
EstimatedParameter[] p = new EstimatedParameter[] {
new EstimatedParameter("p0", 0),
new EstimatedParameter("p1", 0),
new EstimatedParameter("p2", 0),
new EstimatedParameter("p3", 0),
new EstimatedParameter("p4", 0),
new EstimatedParameter("p5", 0)
};
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[0] }, 0.0),
new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[1] }, 1.1),
new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[2] }, 2.2),
new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[3] }, 3.3),
new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[4] }, 4.4),
new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[5] }, 5.5)
});
LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
estimator.estimate(problem);
assertEquals(0, estimator.getRMS(problem), 1.0e-10);
for (int i = 0; i < p.length; ++i) {
assertEquals(0.55 * i, p[i].getEstimate(), 1.0e-10);
}
}
public void testOneSet() throws EstimationException {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 0),
new EstimatedParameter("p1", 0),
new EstimatedParameter("p2", 0)
};
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 1.0 },
new EstimatedParameter[] { p[0] },
1.0),
new LinearMeasurement(new double[] { -1.0, 1.0 },
new EstimatedParameter[] { p[0], p[1] },
1.0),
new LinearMeasurement(new double[] { -1.0, 1.0 },
new EstimatedParameter[] { p[1], p[2] },
1.0)
});
LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
estimator.estimate(problem);
assertEquals(0, estimator.getRMS(problem), 1.0e-10);
assertEquals(1.0, p[0].getEstimate(), 1.0e-10);
assertEquals(2.0, p[1].getEstimate(), 1.0e-10);
assertEquals(3.0, p[2].getEstimate(), 1.0e-10);
}
public void testTwoSets() throws EstimationException {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 0),
new EstimatedParameter("p1", 1),
new EstimatedParameter("p2", 2),
new EstimatedParameter("p3", 3),
new EstimatedParameter("p4", 4),
new EstimatedParameter("p5", 5)
};
double epsilon = 1.0e-7;
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
// 4 elements sub-problem
new LinearMeasurement(new double[] { 2.0, 1.0, 4.0 },
new EstimatedParameter[] { p[0], p[1], p[3] },
2.0),
new LinearMeasurement(new double[] { -4.0, -2.0, 3.0, -7.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
-9.0),
new LinearMeasurement(new double[] { 4.0, 1.0, -2.0, 8.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
2.0),
new LinearMeasurement(new double[] { -3.0, -12.0, -1.0 },
new EstimatedParameter[] { p[1], p[2], p[3] },
2.0),
// 2 elements sub-problem
new LinearMeasurement(new double[] { epsilon, 1.0 },
new EstimatedParameter[] { p[4], p[5] },
1.0 + epsilon * epsilon),
new LinearMeasurement(new double[] { 1.0, 1.0 },
new EstimatedParameter[] { p[4], p[5] },
2.0)
});
LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
estimator.estimate(problem);
assertEquals(0, estimator.getRMS(problem), 1.0e-10);
assertEquals( 3.0, p[0].getEstimate(), 1.0e-10);
assertEquals( 4.0, p[1].getEstimate(), 1.0e-10);
assertEquals(-1.0, p[2].getEstimate(), 1.0e-10);
assertEquals(-2.0, p[3].getEstimate(), 1.0e-10);
assertEquals( 1.0 + epsilon, p[4].getEstimate(), 1.0e-10);
assertEquals( 1.0 - epsilon, p[5].getEstimate(), 1.0e-10);
}
public void testNonInversible() throws EstimationException {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 0),
new EstimatedParameter("p1", 0),
new EstimatedParameter("p2", 0)
};
LinearMeasurement[] m = new LinearMeasurement[] {
new LinearMeasurement(new double[] { 1.0, 2.0, -3.0 },
new EstimatedParameter[] { p[0], p[1], p[2] },
1.0),
new LinearMeasurement(new double[] { 2.0, 1.0, 3.0 },
new EstimatedParameter[] { p[0], p[1], p[2] },
1.0),
new LinearMeasurement(new double[] { -3.0, -9.0 },
new EstimatedParameter[] { p[0], p[2] },
1.0)
};
LinearProblem problem = new LinearProblem(m);
LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
double initialCost = estimator.getRMS(problem);
estimator.estimate(problem);
assertTrue(estimator.getRMS(problem) < initialCost);
assertTrue(FastMath.sqrt(m.length) * estimator.getRMS(problem) > 0.6);
try {
estimator.getCovariances(problem);
fail("an exception should have been thrown");
} catch (EstimationException ee) {
// expected behavior
}
double dJ0 = 2 * (m[0].getResidual() * m[0].getPartial(p[0])
+ m[1].getResidual() * m[1].getPartial(p[0])
+ m[2].getResidual() * m[2].getPartial(p[0]));
double dJ1 = 2 * (m[0].getResidual() * m[0].getPartial(p[1])
+ m[1].getResidual() * m[1].getPartial(p[1]));
double dJ2 = 2 * (m[0].getResidual() * m[0].getPartial(p[2])
+ m[1].getResidual() * m[1].getPartial(p[2])
+ m[2].getResidual() * m[2].getPartial(p[2]));
assertEquals(0, dJ0, 1.0e-10);
assertEquals(0, dJ1, 1.0e-10);
assertEquals(0, dJ2, 1.0e-10);
}
public void testIllConditioned() throws EstimationException {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 0),
new EstimatedParameter("p1", 1),
new EstimatedParameter("p2", 2),
new EstimatedParameter("p3", 3)
};
LinearProblem problem1 = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 10.0, 7.0, 8.0, 7.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
32.0),
new LinearMeasurement(new double[] { 7.0, 5.0, 6.0, 5.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
23.0),
new LinearMeasurement(new double[] { 8.0, 6.0, 10.0, 9.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
33.0),
new LinearMeasurement(new double[] { 7.0, 5.0, 9.0, 10.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
31.0)
});
LevenbergMarquardtEstimator estimator1 = new LevenbergMarquardtEstimator();
estimator1.estimate(problem1);
assertEquals(0, estimator1.getRMS(problem1), 1.0e-10);
assertEquals(1.0, p[0].getEstimate(), 1.0e-10);
assertEquals(1.0, p[1].getEstimate(), 1.0e-10);
assertEquals(1.0, p[2].getEstimate(), 1.0e-10);
assertEquals(1.0, p[3].getEstimate(), 1.0e-10);
LinearProblem problem2 = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 10.0, 7.0, 8.1, 7.2 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
32.0),
new LinearMeasurement(new double[] { 7.08, 5.04, 6.0, 5.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
23.0),
new LinearMeasurement(new double[] { 8.0, 5.98, 9.89, 9.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
33.0),
new LinearMeasurement(new double[] { 6.99, 4.99, 9.0, 9.98 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
31.0)
});
LevenbergMarquardtEstimator estimator2 = new LevenbergMarquardtEstimator();
estimator2.estimate(problem2);
assertEquals(0, estimator2.getRMS(problem2), 1.0e-10);
assertEquals(-81.0, p[0].getEstimate(), 1.0e-8);
assertEquals(137.0, p[1].getEstimate(), 1.0e-8);
assertEquals(-34.0, p[2].getEstimate(), 1.0e-8);
assertEquals( 22.0, p[3].getEstimate(), 1.0e-8);
}
public void testMoreEstimatedParametersSimple() throws EstimationException {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 7),
new EstimatedParameter("p1", 6),
new EstimatedParameter("p2", 5),
new EstimatedParameter("p3", 4)
};
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 3.0, 2.0 },
new EstimatedParameter[] { p[0], p[1] },
7.0),
new LinearMeasurement(new double[] { 1.0, -1.0, 1.0 },
new EstimatedParameter[] { p[1], p[2], p[3] },
3.0),
new LinearMeasurement(new double[] { 2.0, 1.0 },
new EstimatedParameter[] { p[0], p[2] },
5.0)
});
LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
estimator.estimate(problem);
assertEquals(0, estimator.getRMS(problem), 1.0e-10);
}
public void testMoreEstimatedParametersUnsorted() throws EstimationException {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 2),
new EstimatedParameter("p1", 2),
new EstimatedParameter("p2", 2),
new EstimatedParameter("p3", 2),
new EstimatedParameter("p4", 2),
new EstimatedParameter("p5", 2)
};
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 1.0, 1.0 },
new EstimatedParameter[] { p[0], p[1] },
3.0),
new LinearMeasurement(new double[] { 1.0, 1.0, 1.0 },
new EstimatedParameter[] { p[2], p[3], p[4] },
12.0),
new LinearMeasurement(new double[] { 1.0, -1.0 },
new EstimatedParameter[] { p[4], p[5] },
-1.0),
new LinearMeasurement(new double[] { 1.0, -1.0, 1.0 },
new EstimatedParameter[] { p[3], p[2], p[5] },
7.0),
new LinearMeasurement(new double[] { 1.0, -1.0 },
new EstimatedParameter[] { p[4], p[3] },
1.0)
});
LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
estimator.estimate(problem);
assertEquals(0, estimator.getRMS(problem), 1.0e-10);
assertEquals(3.0, p[2].getEstimate(), 1.0e-10);
assertEquals(4.0, p[3].getEstimate(), 1.0e-10);
assertEquals(5.0, p[4].getEstimate(), 1.0e-10);
assertEquals(6.0, p[5].getEstimate(), 1.0e-10);
}
public void testRedundantEquations() throws EstimationException {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 1),
new EstimatedParameter("p1", 1)
};
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 1.0, 1.0 },
new EstimatedParameter[] { p[0], p[1] },
3.0),
new LinearMeasurement(new double[] { 1.0, -1.0 },
new EstimatedParameter[] { p[0], p[1] },
1.0),
new LinearMeasurement(new double[] { 1.0, 3.0 },
new EstimatedParameter[] { p[0], p[1] },
5.0)
});
LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
estimator.estimate(problem);
assertEquals(0, estimator.getRMS(problem), 1.0e-10);
assertEquals(2.0, p[0].getEstimate(), 1.0e-10);
assertEquals(1.0, p[1].getEstimate(), 1.0e-10);
}
public void testInconsistentEquations() throws EstimationException {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 1),
new EstimatedParameter("p1", 1)
};
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 1.0, 1.0 },
new EstimatedParameter[] { p[0], p[1] },
3.0),
new LinearMeasurement(new double[] { 1.0, -1.0 },
new EstimatedParameter[] { p[0], p[1] },
1.0),
new LinearMeasurement(new double[] { 1.0, 3.0 },
new EstimatedParameter[] { p[0], p[1] },
4.0)
});
LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
estimator.estimate(problem);
assertTrue(estimator.getRMS(problem) > 0.1);
}
public void testControlParameters() {
Circle circle = new Circle(98.680, 47.345);
circle.addPoint( 30.0, 68.0);
circle.addPoint( 50.0, -6.0);
circle.addPoint(110.0, -20.0);
circle.addPoint( 35.0, 15.0);
circle.addPoint( 45.0, 97.0);
checkEstimate(circle, 0.1, 10, 1.0e-14, 1.0e-16, 1.0e-10, false);
checkEstimate(circle, 0.1, 10, 1.0e-15, 1.0e-17, 1.0e-10, true);
checkEstimate(circle, 0.1, 5, 1.0e-15, 1.0e-16, 1.0e-10, true);
circle.addPoint(300, -300);
checkEstimate(circle, 0.1, 20, 1.0e-18, 1.0e-16, 1.0e-10, true);
}
private void checkEstimate(EstimationProblem problem,
double initialStepBoundFactor, int maxCostEval,
double costRelativeTolerance, double parRelativeTolerance,
double orthoTolerance, boolean shouldFail) {
try {
LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
estimator.setInitialStepBoundFactor(initialStepBoundFactor);
estimator.setMaxCostEval(maxCostEval);
estimator.setCostRelativeTolerance(costRelativeTolerance);
estimator.setParRelativeTolerance(parRelativeTolerance);
estimator.setOrthoTolerance(orthoTolerance);
estimator.estimate(problem);
assertTrue(! shouldFail);
} catch (EstimationException ee) {
assertTrue(shouldFail);
}
}
public void testCircleFitting() throws EstimationException {
Circle circle = new Circle(98.680, 47.345);
circle.addPoint( 30.0, 68.0);
circle.addPoint( 50.0, -6.0);
circle.addPoint(110.0, -20.0);
circle.addPoint( 35.0, 15.0);
circle.addPoint( 45.0, 97.0);
LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
estimator.estimate(circle);
assertTrue(estimator.getCostEvaluations() < 10);
assertTrue(estimator.getJacobianEvaluations() < 10);
double rms = estimator.getRMS(circle);
assertEquals(1.768262623567235, FastMath.sqrt(circle.getM()) * rms, 1.0e-10);
assertEquals(69.96016176931406, circle.getRadius(), 1.0e-10);
assertEquals(96.07590211815305, circle.getX(), 1.0e-10);
assertEquals(48.13516790438953, circle.getY(), 1.0e-10);
double[][] cov = estimator.getCovariances(circle);
assertEquals(1.839, cov[0][0], 0.001);
assertEquals(0.731, cov[0][1], 0.001);
assertEquals(cov[0][1], cov[1][0], 1.0e-14);
assertEquals(0.786, cov[1][1], 0.001);
double[] errors = estimator.guessParametersErrors(circle);
assertEquals(1.384, errors[0], 0.001);
assertEquals(0.905, errors[1], 0.001);
// add perfect measurements and check errors are reduced
double cx = circle.getX();
double cy = circle.getY();
double r = circle.getRadius();
for (double d= 0; d < 2 * FastMath.PI; d += 0.01) {
circle.addPoint(cx + r * FastMath.cos(d), cy + r * FastMath.sin(d));
}
estimator = new LevenbergMarquardtEstimator();
estimator.estimate(circle);
cov = estimator.getCovariances(circle);
assertEquals(0.004, cov[0][0], 0.001);
assertEquals(6.40e-7, cov[0][1], 1.0e-9);
assertEquals(cov[0][1], cov[1][0], 1.0e-14);
assertEquals(0.003, cov[1][1], 0.001);
errors = estimator.guessParametersErrors(circle);
assertEquals(0.004, errors[0], 0.001);
assertEquals(0.004, errors[1], 0.001);
}
public void testCircleFittingBadInit() throws EstimationException {
Circle circle = new Circle(-12, -12);
double[][] points = new double[][] {
{-0.312967, 0.072366}, {-0.339248, 0.132965}, {-0.379780, 0.202724},
{-0.390426, 0.260487}, {-0.361212, 0.328325}, {-0.346039, 0.392619},
{-0.280579, 0.444306}, {-0.216035, 0.470009}, {-0.149127, 0.493832},
{-0.075133, 0.483271}, {-0.007759, 0.452680}, { 0.060071, 0.410235},
{ 0.103037, 0.341076}, { 0.118438, 0.273884}, { 0.131293, 0.192201},
{ 0.115869, 0.129797}, { 0.072223, 0.058396}, { 0.022884, 0.000718},
{-0.053355, -0.020405}, {-0.123584, -0.032451}, {-0.216248, -0.032862},
{-0.278592, -0.005008}, {-0.337655, 0.056658}, {-0.385899, 0.112526},
{-0.405517, 0.186957}, {-0.415374, 0.262071}, {-0.387482, 0.343398},
{-0.347322, 0.397943}, {-0.287623, 0.458425}, {-0.223502, 0.475513},
{-0.135352, 0.478186}, {-0.061221, 0.483371}, { 0.003711, 0.422737},
{ 0.065054, 0.375830}, { 0.108108, 0.297099}, { 0.123882, 0.222850},
{ 0.117729, 0.134382}, { 0.085195, 0.056820}, { 0.029800, -0.019138},
{-0.027520, -0.072374}, {-0.102268, -0.091555}, {-0.200299, -0.106578},
{-0.292731, -0.091473}, {-0.356288, -0.051108}, {-0.420561, 0.014926},
{-0.471036, 0.074716}, {-0.488638, 0.182508}, {-0.485990, 0.254068},
{-0.463943, 0.338438}, {-0.406453, 0.404704}, {-0.334287, 0.466119},
{-0.254244, 0.503188}, {-0.161548, 0.495769}, {-0.075733, 0.495560},
{ 0.001375, 0.434937}, { 0.082787, 0.385806}, { 0.115490, 0.323807},
{ 0.141089, 0.223450}, { 0.138693, 0.131703}, { 0.126415, 0.049174},
{ 0.066518, -0.010217}, {-0.005184, -0.070647}, {-0.080985, -0.103635},
{-0.177377, -0.116887}, {-0.260628, -0.100258}, {-0.335756, -0.056251},
{-0.405195, -0.000895}, {-0.444937, 0.085456}, {-0.484357, 0.175597},
{-0.472453, 0.248681}, {-0.438580, 0.347463}, {-0.402304, 0.422428},
{-0.326777, 0.479438}, {-0.247797, 0.505581}, {-0.152676, 0.519380},
{-0.071754, 0.516264}, { 0.015942, 0.472802}, { 0.076608, 0.419077},
{ 0.127673, 0.330264}, { 0.159951, 0.262150}, { 0.153530, 0.172681},
{ 0.140653, 0.089229}, { 0.078666, 0.024981}, { 0.023807, -0.037022},
{-0.048837, -0.077056}, {-0.127729, -0.075338}, {-0.221271, -0.067526}
};
for (int i = 0; i < points.length; ++i) {
circle.addPoint(points[i][0], points[i][1]);
}
LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
estimator.estimate(circle);
assertTrue(estimator.getCostEvaluations() < 15);
assertTrue(estimator.getJacobianEvaluations() < 10);
assertEquals( 0.030184491196225207, estimator.getRMS(circle), 1.0e-9);
assertEquals( 0.2922350065939634, circle.getRadius(), 1.0e-9);
assertEquals(-0.15173845023862165, circle.getX(), 1.0e-8);
assertEquals( 0.20750021499570379, circle.getY(), 1.0e-8);
}
public void testMath199() {
try {
QuadraticProblem problem = new QuadraticProblem();
problem.addPoint (0, -3.182591015485607, 0.0);
problem.addPoint (1, -2.5581184967730577, 4.4E-323);
problem.addPoint (2, -2.1488478161387325, 1.0);
problem.addPoint (3, -1.9122489313410047, 4.4E-323);
problem.addPoint (4, 1.7785661310051026, 0.0);
new LevenbergMarquardtEstimator().estimate(problem);
fail("an exception should have been thrown");
} catch (EstimationException ee) {
// expected behavior
}
}
private static class LinearProblem implements EstimationProblem {
public LinearProblem(LinearMeasurement[] measurements) {
this.measurements = measurements;
}
public WeightedMeasurement[] getMeasurements() {
return measurements;
}
public EstimatedParameter[] getUnboundParameters() {
return getAllParameters();
}
public EstimatedParameter[] getAllParameters() {
HashSet set = new HashSet();
for (int i = 0; i < measurements.length; ++i) {
EstimatedParameter[] parameters = measurements[i].getParameters();
for (int j = 0; j < parameters.length; ++j) {
set.add(parameters[j]);
}
}
return set.toArray(new EstimatedParameter[set.size()]);
}
private LinearMeasurement[] measurements;
}
private static class LinearMeasurement extends WeightedMeasurement {
public LinearMeasurement(double[] factors, EstimatedParameter[] parameters,
double setPoint) {
super(1.0, setPoint);
this.factors = factors;
this.parameters = parameters;
}
@Override
public double getTheoreticalValue() {
double v = 0;
for (int i = 0; i < factors.length; ++i) {
v += factors[i] * parameters[i].getEstimate();
}
return v;
}
@Override
public double getPartial(EstimatedParameter parameter) {
for (int i = 0; i < parameters.length; ++i) {
if (parameters[i] == parameter) {
return factors[i];
}
}
return 0;
}
public EstimatedParameter[] getParameters() {
return parameters;
}
private double[] factors;
private EstimatedParameter[] parameters;
private static final long serialVersionUID = -3922448707008868580L;
}
private static class Circle implements EstimationProblem {
public Circle(double cx, double cy) {
this.cx = new EstimatedParameter("cx", cx);
this.cy = new EstimatedParameter("cy", cy);
points = new ArrayList();
}
public void addPoint(double px, double py) {
points.add(new PointModel(this, px, py));
}
public int getM() {
return points.size();
}
public WeightedMeasurement[] getMeasurements() {
return points.toArray(new PointModel[points.size()]);
}
public EstimatedParameter[] getAllParameters() {
return new EstimatedParameter[] { cx, cy };
}
public EstimatedParameter[] getUnboundParameters() {
return new EstimatedParameter[] { cx, cy };
}
public double getPartialRadiusX() {
double dRdX = 0;
for (PointModel point : points) {
dRdX += point.getPartialDiX();
}
return dRdX / points.size();
}
public double getPartialRadiusY() {
double dRdY = 0;
for (PointModel point : points) {
dRdY += point.getPartialDiY();
}
return dRdY / points.size();
}
public double getRadius() {
double r = 0;
for (PointModel point : points) {
r += point.getCenterDistance();
}
return r / points.size();
}
public double getX() {
return cx.getEstimate();
}
public double getY() {
return cy.getEstimate();
}
private static class PointModel extends WeightedMeasurement {
public PointModel(Circle circle, double px, double py) {
super(1.0, 0.0);
this.px = px;
this.py = py;
this.circle = circle;
}
@Override
public double getPartial(EstimatedParameter parameter) {
if (parameter == circle.cx) {
return getPartialDiX() - circle.getPartialRadiusX();
} else if (parameter == circle.cy) {
return getPartialDiY() - circle.getPartialRadiusY();
}
return 0;
}
public double getCenterDistance() {
double dx = px - circle.cx.getEstimate();
double dy = py - circle.cy.getEstimate();
return FastMath.sqrt(dx * dx + dy * dy);
}
public double getPartialDiX() {
return (circle.cx.getEstimate() - px) / getCenterDistance();
}
public double getPartialDiY() {
return (circle.cy.getEstimate() - py) / getCenterDistance();
}
@Override
public double getTheoreticalValue() {
return getCenterDistance() - circle.getRadius();
}
private double px;
private double py;
private transient final Circle circle;
private static final long serialVersionUID = 1L;
}
private EstimatedParameter cx;
private EstimatedParameter cy;
private ArrayList points;
}
private static class QuadraticProblem extends SimpleEstimationProblem {
private EstimatedParameter a;
private EstimatedParameter b;
private EstimatedParameter c;
public QuadraticProblem() {
a = new EstimatedParameter("a", 0.0);
b = new EstimatedParameter("b", 0.0);
c = new EstimatedParameter("c", 0.0);
addParameter(a);
addParameter(b);
addParameter(c);
}
public void addPoint(double x, double y, double w) {
addMeasurement(new LocalMeasurement(this, x, y, w));
}
public double theoreticalValue(double x) {
return ( (a.getEstimate() * x + b.getEstimate() ) * x + c.getEstimate());
}
private double partial(double x, EstimatedParameter parameter) {
if (parameter == a) {
return x * x;
} else if (parameter == b) {
return x;
} else {
return 1.0;
}
}
private static class LocalMeasurement extends WeightedMeasurement {
private static final long serialVersionUID = 1555043155023729130L;
private final double x;
private transient final QuadraticProblem pb;
// constructor
public LocalMeasurement(QuadraticProblem pb, double x, double y, double w) {
super(w, y);
this.x = x;
this.pb = pb;
}
@Override
public double getTheoreticalValue() {
return pb.theoreticalValue(x);
}
@Override
public double getPartial(EstimatedParameter parameter) {
return pb.partial(x, parameter);
}
}
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java 100644 1750 1750 70766 11532241243 32461 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.estimation;
import java.util.ArrayList;
import java.util.HashSet;
import org.apache.commons.math.util.FastMath;
import junit.framework.TestCase;
/**
* Some of the unit tests are re-implementations of the MINPACK file17 and file22 test files.
* The redistribution policy for MINPACK is available here, for
* convenience, it is reproduced below.
*
*
* Minpack Copyright Notice (1999) University of Chicago.
* All rights reserved
* |
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* - The end-user documentation included with the redistribution, if any,
* must include the following acknowledgment:
*
This product includes software developed by the University of
* Chicago, as Operator of Argonne National Laboratory.
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* - WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS"
* WITHOUT WARRANTY OF ANY KIND. THE COPYRIGHT HOLDER, THE
* UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND
* THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE
* OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY
* OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR
* USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF
* THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4)
* DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION
* UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL
* BE CORRECTED.
* - LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT
* HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF
* ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT,
* INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF
* ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF
* PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER
* SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT
* (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE,
* EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE
* POSSIBILITY OF SUCH LOSS OR DAMAGES.
*
|
*
* @author Argonne National Laboratory. MINPACK project. March 1980 (original fortran minpack tests)
* @author Burton S. Garbow (original fortran minpack tests)
* @author Kenneth E. Hillstrom (original fortran minpack tests)
* @author Jorge J. More (original fortran minpack tests)
* @author Luc Maisonobe (non-minpack tests and minpack tests Java translation)
*/
@Deprecated
public class GaussNewtonEstimatorTest
extends TestCase {
public GaussNewtonEstimatorTest(String name) {
super(name);
}
public void testTrivial() throws EstimationException {
LinearProblem problem =
new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] {2},
new EstimatedParameter[] {
new EstimatedParameter("p0", 0)
}, 3.0)
});
GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6);
estimator.estimate(problem);
assertEquals(0, estimator.getRMS(problem), 1.0e-10);
assertEquals(1.5,
problem.getUnboundParameters()[0].getEstimate(),
1.0e-10);
}
public void testQRColumnsPermutation() throws EstimationException {
EstimatedParameter[] x = {
new EstimatedParameter("p0", 0), new EstimatedParameter("p1", 0)
};
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 1.0, -1.0 },
new EstimatedParameter[] { x[0], x[1] },
4.0),
new LinearMeasurement(new double[] { 2.0 },
new EstimatedParameter[] { x[1] },
6.0),
new LinearMeasurement(new double[] { 1.0, -2.0 },
new EstimatedParameter[] { x[0], x[1] },
1.0)
});
GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6);
estimator.estimate(problem);
assertEquals(0, estimator.getRMS(problem), 1.0e-10);
assertEquals(7.0, x[0].getEstimate(), 1.0e-10);
assertEquals(3.0, x[1].getEstimate(), 1.0e-10);
}
public void testNoDependency() throws EstimationException {
EstimatedParameter[] p = new EstimatedParameter[] {
new EstimatedParameter("p0", 0),
new EstimatedParameter("p1", 0),
new EstimatedParameter("p2", 0),
new EstimatedParameter("p3", 0),
new EstimatedParameter("p4", 0),
new EstimatedParameter("p5", 0)
};
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[0] }, 0.0),
new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[1] }, 1.1),
new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[2] }, 2.2),
new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[3] }, 3.3),
new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[4] }, 4.4),
new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[5] }, 5.5)
});
GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6);
estimator.estimate(problem);
assertEquals(0, estimator.getRMS(problem), 1.0e-10);
for (int i = 0; i < p.length; ++i) {
assertEquals(0.55 * i, p[i].getEstimate(), 1.0e-10);
}
}
public void testOneSet() throws EstimationException {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 0),
new EstimatedParameter("p1", 0),
new EstimatedParameter("p2", 0)
};
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 1.0 },
new EstimatedParameter[] { p[0] },
1.0),
new LinearMeasurement(new double[] { -1.0, 1.0 },
new EstimatedParameter[] { p[0], p[1] },
1.0),
new LinearMeasurement(new double[] { -1.0, 1.0 },
new EstimatedParameter[] { p[1], p[2] },
1.0)
});
GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6);
estimator.estimate(problem);
assertEquals(0, estimator.getRMS(problem), 1.0e-10);
assertEquals(1.0, p[0].getEstimate(), 1.0e-10);
assertEquals(2.0, p[1].getEstimate(), 1.0e-10);
assertEquals(3.0, p[2].getEstimate(), 1.0e-10);
}
public void testTwoSets() throws EstimationException {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 0),
new EstimatedParameter("p1", 1),
new EstimatedParameter("p2", 2),
new EstimatedParameter("p3", 3),
new EstimatedParameter("p4", 4),
new EstimatedParameter("p5", 5)
};
double epsilon = 1.0e-7;
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
// 4 elements sub-problem
new LinearMeasurement(new double[] { 2.0, 1.0, 4.0 },
new EstimatedParameter[] { p[0], p[1], p[3] },
2.0),
new LinearMeasurement(new double[] { -4.0, -2.0, 3.0, -7.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
-9.0),
new LinearMeasurement(new double[] { 4.0, 1.0, -2.0, 8.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
2.0),
new LinearMeasurement(new double[] { -3.0, -12.0, -1.0 },
new EstimatedParameter[] { p[1], p[2], p[3] },
2.0),
// 2 elements sub-problem
new LinearMeasurement(new double[] { epsilon, 1.0 },
new EstimatedParameter[] { p[4], p[5] },
1.0 + epsilon * epsilon),
new LinearMeasurement(new double[] { 1.0, 1.0 },
new EstimatedParameter[] { p[4], p[5] },
2.0)
});
GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6);
estimator.estimate(problem);
assertEquals(0, estimator.getRMS(problem), 1.0e-10);
assertEquals( 3.0, p[0].getEstimate(), 1.0e-10);
assertEquals( 4.0, p[1].getEstimate(), 1.0e-10);
assertEquals(-1.0, p[2].getEstimate(), 1.0e-10);
assertEquals(-2.0, p[3].getEstimate(), 1.0e-10);
assertEquals( 1.0 + epsilon, p[4].getEstimate(), 1.0e-10);
assertEquals( 1.0 - epsilon, p[5].getEstimate(), 1.0e-10);
}
public void testNonInversible() {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 0),
new EstimatedParameter("p1", 0),
new EstimatedParameter("p2", 0)
};
LinearMeasurement[] m = new LinearMeasurement[] {
new LinearMeasurement(new double[] { 1.0, 2.0, -3.0 },
new EstimatedParameter[] { p[0], p[1], p[2] },
1.0),
new LinearMeasurement(new double[] { 2.0, 1.0, 3.0 },
new EstimatedParameter[] { p[0], p[1], p[2] },
1.0),
new LinearMeasurement(new double[] { -3.0, -9.0 },
new EstimatedParameter[] { p[0], p[2] },
1.0)
};
LinearProblem problem = new LinearProblem(m);
GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6);
try {
estimator.estimate(problem);
fail("an exception should have been caught");
} catch (EstimationException ee) {
// expected behavior
}
}
public void testIllConditioned() throws EstimationException {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 0),
new EstimatedParameter("p1", 1),
new EstimatedParameter("p2", 2),
new EstimatedParameter("p3", 3)
};
LinearProblem problem1 = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 10.0, 7.0, 8.0, 7.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
32.0),
new LinearMeasurement(new double[] { 7.0, 5.0, 6.0, 5.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
23.0),
new LinearMeasurement(new double[] { 8.0, 6.0, 10.0, 9.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
33.0),
new LinearMeasurement(new double[] { 7.0, 5.0, 9.0, 10.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
31.0)
});
GaussNewtonEstimator estimator1 = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6);
estimator1.estimate(problem1);
assertEquals(0, estimator1.getRMS(problem1), 1.0e-10);
assertEquals(1.0, p[0].getEstimate(), 1.0e-10);
assertEquals(1.0, p[1].getEstimate(), 1.0e-10);
assertEquals(1.0, p[2].getEstimate(), 1.0e-10);
assertEquals(1.0, p[3].getEstimate(), 1.0e-10);
LinearProblem problem2 = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 10.0, 7.0, 8.1, 7.2 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
32.0),
new LinearMeasurement(new double[] { 7.08, 5.04, 6.0, 5.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
23.0),
new LinearMeasurement(new double[] { 8.0, 5.98, 9.89, 9.0 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
33.0),
new LinearMeasurement(new double[] { 6.99, 4.99, 9.0, 9.98 },
new EstimatedParameter[] { p[0], p[1], p[2], p[3] },
31.0)
});
GaussNewtonEstimator estimator2 = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6);
estimator2.estimate(problem2);
assertEquals(0, estimator2.getRMS(problem2), 1.0e-10);
assertEquals(-81.0, p[0].getEstimate(), 1.0e-8);
assertEquals(137.0, p[1].getEstimate(), 1.0e-8);
assertEquals(-34.0, p[2].getEstimate(), 1.0e-8);
assertEquals( 22.0, p[3].getEstimate(), 1.0e-8);
}
public void testMoreEstimatedParametersSimple() {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 7),
new EstimatedParameter("p1", 6),
new EstimatedParameter("p2", 5),
new EstimatedParameter("p3", 4)
};
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 3.0, 2.0 },
new EstimatedParameter[] { p[0], p[1] },
7.0),
new LinearMeasurement(new double[] { 1.0, -1.0, 1.0 },
new EstimatedParameter[] { p[1], p[2], p[3] },
3.0),
new LinearMeasurement(new double[] { 2.0, 1.0 },
new EstimatedParameter[] { p[0], p[2] },
5.0)
});
GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6);
try {
estimator.estimate(problem);
fail("an exception should have been caught");
} catch (EstimationException ee) {
// expected behavior
}
}
public void testMoreEstimatedParametersUnsorted() {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 2),
new EstimatedParameter("p1", 2),
new EstimatedParameter("p2", 2),
new EstimatedParameter("p3", 2),
new EstimatedParameter("p4", 2),
new EstimatedParameter("p5", 2)
};
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 1.0, 1.0 },
new EstimatedParameter[] { p[0], p[1] },
3.0),
new LinearMeasurement(new double[] { 1.0, 1.0, 1.0 },
new EstimatedParameter[] { p[2], p[3], p[4] },
12.0),
new LinearMeasurement(new double[] { 1.0, -1.0 },
new EstimatedParameter[] { p[4], p[5] },
-1.0),
new LinearMeasurement(new double[] { 1.0, -1.0, 1.0 },
new EstimatedParameter[] { p[3], p[2], p[5] },
7.0),
new LinearMeasurement(new double[] { 1.0, -1.0 },
new EstimatedParameter[] { p[4], p[3] },
1.0)
});
GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6);
try {
estimator.estimate(problem);
fail("an exception should have been caught");
} catch (EstimationException ee) {
// expected behavior
}
}
public void testRedundantEquations() throws EstimationException {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 1),
new EstimatedParameter("p1", 1)
};
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 1.0, 1.0 },
new EstimatedParameter[] { p[0], p[1] },
3.0),
new LinearMeasurement(new double[] { 1.0, -1.0 },
new EstimatedParameter[] { p[0], p[1] },
1.0),
new LinearMeasurement(new double[] { 1.0, 3.0 },
new EstimatedParameter[] { p[0], p[1] },
5.0)
});
GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6);
estimator.estimate(problem);
assertEquals(0, estimator.getRMS(problem), 1.0e-10);
EstimatedParameter[] all = problem.getAllParameters();
for (int i = 0; i < all.length; ++i) {
assertEquals(all[i].getName().equals("p0") ? 2.0 : 1.0,
all[i].getEstimate(), 1.0e-10);
}
}
public void testInconsistentEquations() throws EstimationException {
EstimatedParameter[] p = {
new EstimatedParameter("p0", 1),
new EstimatedParameter("p1", 1)
};
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 1.0, 1.0 },
new EstimatedParameter[] { p[0], p[1] },
3.0),
new LinearMeasurement(new double[] { 1.0, -1.0 },
new EstimatedParameter[] { p[0], p[1] },
1.0),
new LinearMeasurement(new double[] { 1.0, 3.0 },
new EstimatedParameter[] { p[0], p[1] },
4.0)
});
GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6);
estimator.estimate(problem);
assertTrue(estimator.getRMS(problem) > 0.1);
}
public void testBoundParameters() throws EstimationException {
EstimatedParameter[] p = {
new EstimatedParameter("unbound0", 2, false),
new EstimatedParameter("unbound1", 2, false),
new EstimatedParameter("bound", 2, true)
};
LinearProblem problem = new LinearProblem(new LinearMeasurement[] {
new LinearMeasurement(new double[] { 1.0, 1.0, 1.0 },
new EstimatedParameter[] { p[0], p[1], p[2] },
3.0),
new LinearMeasurement(new double[] { 1.0, -1.0, 1.0 },
new EstimatedParameter[] { p[0], p[1], p[2] },
1.0),
new LinearMeasurement(new double[] { 1.0, 3.0, 2.0 },
new EstimatedParameter[] { p[0], p[1], p[2] },
7.0)
});
GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6);
estimator.estimate(problem);
assertTrue(estimator.getRMS(problem) < 1.0e-10);
double[][] covariances = estimator.getCovariances(problem);
int i0 = 0, i1 = 1;
if (problem.getUnboundParameters()[0].getName().endsWith("1")) {
i0 = 1;
i1 = 0;
}
assertEquals(11.0 / 24, covariances[i0][i0], 1.0e-10);
assertEquals(-3.0 / 24, covariances[i0][i1], 1.0e-10);
assertEquals(-3.0 / 24, covariances[i1][i0], 1.0e-10);
assertEquals( 3.0 / 24, covariances[i1][i1], 1.0e-10);
double[] errors = estimator.guessParametersErrors(problem);
assertEquals(0, errors[i0], 1.0e-10);
assertEquals(0, errors[i1], 1.0e-10);
}
public void testMaxIterations() {
Circle circle = new Circle(98.680, 47.345);
circle.addPoint( 30.0, 68.0);
circle.addPoint( 50.0, -6.0);
circle.addPoint(110.0, -20.0);
circle.addPoint( 35.0, 15.0);
circle.addPoint( 45.0, 97.0);
try {
GaussNewtonEstimator estimator = new GaussNewtonEstimator(4, 1.0e-14, 1.0e-14);
estimator.estimate(circle);
fail("an exception should have been caught");
} catch (EstimationException ee) {
// expected behavior
}
}
public void testCircleFitting() throws EstimationException {
Circle circle = new Circle(98.680, 47.345);
circle.addPoint( 30.0, 68.0);
circle.addPoint( 50.0, -6.0);
circle.addPoint(110.0, -20.0);
circle.addPoint( 35.0, 15.0);
circle.addPoint( 45.0, 97.0);
GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-10, 1.0e-10);
estimator.estimate(circle);
double rms = estimator.getRMS(circle);
assertEquals(1.768262623567235, FastMath.sqrt(circle.getM()) * rms, 1.0e-10);
assertEquals(69.96016176931406, circle.getRadius(), 1.0e-10);
assertEquals(96.07590211815305, circle.getX(), 1.0e-10);
assertEquals(48.13516790438953, circle.getY(), 1.0e-10);
}
public void testCircleFittingBadInit() {
Circle circle = new Circle(-12, -12);
double[][] points = new double[][] {
{-0.312967, 0.072366}, {-0.339248, 0.132965}, {-0.379780, 0.202724},
{-0.390426, 0.260487}, {-0.361212, 0.328325}, {-0.346039, 0.392619},
{-0.280579, 0.444306}, {-0.216035, 0.470009}, {-0.149127, 0.493832},
{-0.075133, 0.483271}, {-0.007759, 0.452680}, { 0.060071, 0.410235},
{ 0.103037, 0.341076}, { 0.118438, 0.273884}, { 0.131293, 0.192201},
{ 0.115869, 0.129797}, { 0.072223, 0.058396}, { 0.022884, 0.000718},
{-0.053355, -0.020405}, {-0.123584, -0.032451}, {-0.216248, -0.032862},
{-0.278592, -0.005008}, {-0.337655, 0.056658}, {-0.385899, 0.112526},
{-0.405517, 0.186957}, {-0.415374, 0.262071}, {-0.387482, 0.343398},
{-0.347322, 0.397943}, {-0.287623, 0.458425}, {-0.223502, 0.475513},
{-0.135352, 0.478186}, {-0.061221, 0.483371}, { 0.003711, 0.422737},
{ 0.065054, 0.375830}, { 0.108108, 0.297099}, { 0.123882, 0.222850},
{ 0.117729, 0.134382}, { 0.085195, 0.056820}, { 0.029800, -0.019138},
{-0.027520, -0.072374}, {-0.102268, -0.091555}, {-0.200299, -0.106578},
{-0.292731, -0.091473}, {-0.356288, -0.051108}, {-0.420561, 0.014926},
{-0.471036, 0.074716}, {-0.488638, 0.182508}, {-0.485990, 0.254068},
{-0.463943, 0.338438}, {-0.406453, 0.404704}, {-0.334287, 0.466119},
{-0.254244, 0.503188}, {-0.161548, 0.495769}, {-0.075733, 0.495560},
{ 0.001375, 0.434937}, { 0.082787, 0.385806}, { 0.115490, 0.323807},
{ 0.141089, 0.223450}, { 0.138693, 0.131703}, { 0.126415, 0.049174},
{ 0.066518, -0.010217}, {-0.005184, -0.070647}, {-0.080985, -0.103635},
{-0.177377, -0.116887}, {-0.260628, -0.100258}, {-0.335756, -0.056251},
{-0.405195, -0.000895}, {-0.444937, 0.085456}, {-0.484357, 0.175597},
{-0.472453, 0.248681}, {-0.438580, 0.347463}, {-0.402304, 0.422428},
{-0.326777, 0.479438}, {-0.247797, 0.505581}, {-0.152676, 0.519380},
{-0.071754, 0.516264}, { 0.015942, 0.472802}, { 0.076608, 0.419077},
{ 0.127673, 0.330264}, { 0.159951, 0.262150}, { 0.153530, 0.172681},
{ 0.140653, 0.089229}, { 0.078666, 0.024981}, { 0.023807, -0.037022},
{-0.048837, -0.077056}, {-0.127729, -0.075338}, {-0.221271, -0.067526}
};
for (int i = 0; i < points.length; ++i) {
circle.addPoint(points[i][0], points[i][1]);
}
GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-6, 1.0e-6);
try {
estimator.estimate(circle);
fail("an exception should have been caught");
} catch (EstimationException ee) {
// expected behavior
}
}
private static class LinearProblem extends SimpleEstimationProblem {
public LinearProblem(LinearMeasurement[] measurements) {
HashSet set = new HashSet();
for (int i = 0; i < measurements.length; ++i) {
addMeasurement(measurements[i]);
EstimatedParameter[] parameters = measurements[i].getParameters();
for (int j = 0; j < parameters.length; ++j) {
set.add(parameters[j]);
}
}
for (EstimatedParameter p : set) {
addParameter(p);
}
}
}
private static class LinearMeasurement extends WeightedMeasurement {
public LinearMeasurement(double[] factors, EstimatedParameter[] parameters,
double setPoint) {
super(1.0, setPoint, true);
this.factors = factors;
this.parameters = parameters;
setIgnored(false);
}
@Override
public double getTheoreticalValue() {
double v = 0;
for (int i = 0; i < factors.length; ++i) {
v += factors[i] * parameters[i].getEstimate();
}
return v;
}
@Override
public double getPartial(EstimatedParameter parameter) {
for (int i = 0; i < parameters.length; ++i) {
if (parameters[i] == parameter) {
return factors[i];
}
}
return 0;
}
public EstimatedParameter[] getParameters() {
return parameters;
}
private double[] factors;
private EstimatedParameter[] parameters;
private static final long serialVersionUID = -3922448707008868580L;
}
private static class Circle implements EstimationProblem {
public Circle(double cx, double cy) {
this.cx = new EstimatedParameter("cx", cx);
this.cy = new EstimatedParameter(new EstimatedParameter("cy", cy));
points = new ArrayList();
}
public void addPoint(double px, double py) {
points.add(new PointModel(this, px, py));
}
public int getM() {
return points.size();
}
public WeightedMeasurement[] getMeasurements() {
return points.toArray(new PointModel[points.size()]);
}
public EstimatedParameter[] getAllParameters() {
return new EstimatedParameter[] { cx, cy };
}
public EstimatedParameter[] getUnboundParameters() {
return new EstimatedParameter[] { cx, cy };
}
public double getPartialRadiusX() {
double dRdX = 0;
for (PointModel point : points) {
dRdX += point.getPartialDiX();
}
return dRdX / points.size();
}
public double getPartialRadiusY() {
double dRdY = 0;
for (PointModel point : points) {
dRdY += point.getPartialDiY();
}
return dRdY / points.size();
}
public double getRadius() {
double r = 0;
for (PointModel point : points) {
r += point.getCenterDistance();
}
return r / points.size();
}
public double getX() {
return cx.getEstimate();
}
public double getY() {
return cy.getEstimate();
}
private static class PointModel extends WeightedMeasurement {
public PointModel(Circle circle, double px, double py) {
super(1.0, 0.0);
this.px = px;
this.py = py;
this.circle = circle;
}
@Override
public double getPartial(EstimatedParameter parameter) {
if (parameter == circle.cx) {
return getPartialDiX() - circle.getPartialRadiusX();
} else if (parameter == circle.cy) {
return getPartialDiY() - circle.getPartialRadiusY();
}
return 0;
}
public double getCenterDistance() {
double dx = px - circle.cx.getEstimate();
double dy = py - circle.cy.getEstimate();
return FastMath.sqrt(dx * dx + dy * dy);
}
public double getPartialDiX() {
return (circle.cx.getEstimate() - px) / getCenterDistance();
}
public double getPartialDiY() {
return (circle.cy.getEstimate() - py) / getCenterDistance();
}
@Override
public double getTheoreticalValue() {
return getCenterDistance() - circle.getRadius();
}
private double px;
private double py;
private transient final Circle circle;
private static final long serialVersionUID = 1L;
}
private EstimatedParameter cx;
private EstimatedParameter cy;
private ArrayList points;
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/estimation/MinpackTest.java 100644 1750 1750 167062 11532241243 27712 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.estimation;
import java.util.Arrays;
import org.apache.commons.math.estimation.EstimatedParameter;
import org.apache.commons.math.estimation.EstimationException;
import org.apache.commons.math.estimation.EstimationProblem;
import org.apache.commons.math.estimation.LevenbergMarquardtEstimator;
import org.apache.commons.math.estimation.WeightedMeasurement;
import org.apache.commons.math.util.FastMath;
import junit.framework.*;
/**
* Some of the unit tests are re-implementations of the MINPACK file17 and file22 test files.
* The redistribution policy for MINPACK is available here, for
* convenience, it is reproduced below.
*
*
* Minpack Copyright Notice (1999) University of Chicago.
* All rights reserved
* |
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* - The end-user documentation included with the redistribution, if any,
* must include the following acknowledgment:
*
This product includes software developed by the University of
* Chicago, as Operator of Argonne National Laboratory.
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
* - WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS"
* WITHOUT WARRANTY OF ANY KIND. THE COPYRIGHT HOLDER, THE
* UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND
* THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE
* OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY
* OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR
* USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF
* THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4)
* DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION
* UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL
* BE CORRECTED.
* - LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT
* HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF
* ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT,
* INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF
* ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF
* PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER
* SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT
* (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE,
* EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE
* POSSIBILITY OF SUCH LOSS OR DAMAGES.
*
|
*
* @author Argonne National Laboratory. MINPACK project. March 1980 (original fortran minpack tests)
* @author Burton S. Garbow (original fortran minpack tests)
* @author Kenneth E. Hillstrom (original fortran minpack tests)
* @author Jorge J. More (original fortran minpack tests)
* @author Luc Maisonobe (non-minpack tests and minpack tests Java translation)
*/
@Deprecated
public class MinpackTest
extends TestCase {
public MinpackTest(String name) {
super(name);
}
public void testMinpackLinearFullRank() {
minpackTest(new LinearFullRankFunction(10, 5, 1.0,
5.0, 2.23606797749979), false);
minpackTest(new LinearFullRankFunction(50, 5, 1.0,
8.06225774829855, 6.70820393249937), false);
}
public void testMinpackLinearRank1() {
minpackTest(new LinearRank1Function(10, 5, 1.0,
291.521868819476, 1.4638501094228), false);
minpackTest(new LinearRank1Function(50, 5, 1.0,
3101.60039334535, 3.48263016573496), false);
}
public void testMinpackLinearRank1ZeroColsAndRows() {
minpackTest(new LinearRank1ZeroColsAndRowsFunction(10, 5, 1.0), false);
minpackTest(new LinearRank1ZeroColsAndRowsFunction(50, 5, 1.0), false);
}
public void testMinpackRosenbrok() {
minpackTest(new RosenbrockFunction(new double[] { -1.2, 1.0 },
FastMath.sqrt(24.2)), false);
minpackTest(new RosenbrockFunction(new double[] { -12.0, 10.0 },
FastMath.sqrt(1795769.0)), false);
minpackTest(new RosenbrockFunction(new double[] { -120.0, 100.0 },
11.0 * FastMath.sqrt(169000121.0)), false);
}
public void testMinpackHelicalValley() {
minpackTest(new HelicalValleyFunction(new double[] { -1.0, 0.0, 0.0 },
50.0), false);
minpackTest(new HelicalValleyFunction(new double[] { -10.0, 0.0, 0.0 },
102.95630140987), false);
minpackTest(new HelicalValleyFunction(new double[] { -100.0, 0.0, 0.0},
991.261822123701), false);
}
public void testMinpackPowellSingular() {
minpackTest(new PowellSingularFunction(new double[] { 3.0, -1.0, 0.0, 1.0 },
14.6628782986152), false);
minpackTest(new PowellSingularFunction(new double[] { 30.0, -10.0, 0.0, 10.0 },
1270.9838708654), false);
minpackTest(new PowellSingularFunction(new double[] { 300.0, -100.0, 0.0, 100.0 },
126887.903284750), false);
}
public void testMinpackFreudensteinRoth() {
minpackTest(new FreudensteinRothFunction(new double[] { 0.5, -2.0 },
20.0124960961895, 6.99887517584575,
new double[] {
11.4124844654993,
-0.896827913731509
}), false);
minpackTest(new FreudensteinRothFunction(new double[] { 5.0, -20.0 },
12432.833948863, 6.9988751744895,
new double[] {
11.4130046614746,
-0.896796038685958
}), false);
minpackTest(new FreudensteinRothFunction(new double[] { 50.0, -200.0 },
11426454.595762, 6.99887517242903,
new double[] {
11.4127817857886,
-0.89680510749204
}), false);
}
public void testMinpackBard() {
minpackTest(new BardFunction(1.0, 6.45613629515967, 0.0906359603390466,
new double[] {
0.0824105765758334,
1.1330366534715,
2.34369463894115
}), false);
minpackTest(new BardFunction(10.0, 36.1418531596785, 4.17476870138539,
new double[] {
0.840666673818329,
-158848033.259565,
-164378671.653535
}), false);
minpackTest(new BardFunction(100.0, 384.114678637399, 4.17476870135969,
new double[] {
0.840666673867645,
-158946167.205518,
-164464906.857771
}), false);
}
public void testMinpackKowalikOsborne() {
minpackTest(new KowalikOsborneFunction(new double[] { 0.25, 0.39, 0.415, 0.39 },
0.0728915102882945,
0.017535837721129,
new double[] {
0.192807810476249,
0.191262653354071,
0.123052801046931,
0.136053221150517
}), false);
minpackTest(new KowalikOsborneFunction(new double[] { 2.5, 3.9, 4.15, 3.9 },
2.97937007555202,
0.032052192917937,
new double[] {
728675.473768287,
-14.0758803129393,
-32977797.7841797,
-20571594.1977912
}), false);
minpackTest(new KowalikOsborneFunction(new double[] { 25.0, 39.0, 41.5, 39.0 },
29.9590617016037,
0.0175364017658228,
new double[] {
0.192948328597594,
0.188053165007911,
0.122430604321144,
0.134575665392506
}), true);
}
public void testMinpackMeyer() {
minpackTest(new MeyerFunction(new double[] { 0.02, 4000.0, 250.0 },
41153.4665543031, 9.37794514651874,
new double[] {
0.00560963647102661,
6181.34634628659,
345.223634624144
}), false);
minpackTest(new MeyerFunction(new double[] { 0.2, 40000.0, 2500.0 },
4168216.89130846, 792.917871779501,
new double[] {
1.42367074157994e-11,
33695.7133432541,
901.268527953801
}), true);
}
public void testMinpackWatson() {
minpackTest(new WatsonFunction(6, 0.0,
5.47722557505166, 0.0478295939097601,
new double[] {
-0.0157249615083782, 1.01243488232965,
-0.232991722387673, 1.26043101102818,
-1.51373031394421, 0.99299727291842
}), false);
minpackTest(new WatsonFunction(6, 10.0,
6433.12578950026, 0.0478295939096951,
new double[] {
-0.0157251901386677, 1.01243485860105,
-0.232991545843829, 1.26042932089163,
-1.51372776706575, 0.99299573426328
}), false);
minpackTest(new WatsonFunction(6, 100.0,
674256.040605213, 0.047829593911544,
new double[] {
-0.0157247019712586, 1.01243490925658,
-0.232991922761641, 1.26043292929555,
-1.51373320452707, 0.99299901922322
}), false);
minpackTest(new WatsonFunction(9, 0.0,
5.47722557505166, 0.00118311459212420,
new double[] {
-0.153070644166722e-4, 0.999789703934597,
0.0147639634910978, 0.146342330145992,
1.00082109454817, -2.61773112070507,
4.10440313943354, -3.14361226236241,
1.05262640378759
}), false);
minpackTest(new WatsonFunction(9, 10.0,
12088.127069307, 0.00118311459212513,
new double[] {
-0.153071334849279e-4, 0.999789703941234,
0.0147639629786217, 0.146342334818836,
1.00082107321386, -2.61773107084722,
4.10440307655564, -3.14361222178686,
1.05262639322589
}), false);
minpackTest(new WatsonFunction(9, 100.0,
1269109.29043834, 0.00118311459212384,
new double[] {
-0.153069523352176e-4, 0.999789703958371,
0.0147639625185392, 0.146342341096326,
1.00082104729164, -2.61773101573645,
4.10440301427286, -3.14361218602503,
1.05262638516774
}), false);
minpackTest(new WatsonFunction(12, 0.0,
5.47722557505166, 0.217310402535861e-4,
new double[] {
-0.660266001396382e-8, 1.00000164411833,
-0.000563932146980154, 0.347820540050756,
-0.156731500244233, 1.05281515825593,
-3.24727109519451, 7.2884347837505,
-10.271848098614, 9.07411353715783,
-4.54137541918194, 1.01201187975044
}), false);
minpackTest(new WatsonFunction(12, 10.0,
19220.7589790951, 0.217310402518509e-4,
new double[] {
-0.663710223017410e-8, 1.00000164411787,
-0.000563932208347327, 0.347820540486998,
-0.156731503955652, 1.05281517654573,
-3.2472711515214, 7.28843489430665,
-10.2718482369638, 9.07411364383733,
-4.54137546533666, 1.01201188830857
}), false);
minpackTest(new WatsonFunction(12, 100.0,
2018918.04462367, 0.217310402539845e-4,
new double[] {
-0.663806046485249e-8, 1.00000164411786,
-0.000563932210324959, 0.347820540503588,
-0.156731504091375, 1.05281517718031,
-3.24727115337025, 7.28843489775302,
-10.2718482410813, 9.07411364688464,
-4.54137546660822, 1.0120118885369
}), false);
}
public void testMinpackBox3Dimensional() {
minpackTest(new Box3DimensionalFunction(10, new double[] { 0.0, 10.0, 20.0 },
32.1115837449572), false);
}
public void testMinpackJennrichSampson() {
minpackTest(new JennrichSampsonFunction(10, new double[] { 0.3, 0.4 },
64.5856498144943, 11.1517793413499,
new double[] {
0.257819926636811, 0.257829976764542
}), false);
}
public void testMinpackBrownDennis() {
minpackTest(new BrownDennisFunction(20,
new double[] { 25.0, 5.0, -5.0, -1.0 },
2815.43839161816, 292.954288244866,
new double[] {
-11.59125141003, 13.2024883984741,
-0.403574643314272, 0.236736269844604
}), false);
minpackTest(new BrownDennisFunction(20,
new double[] { 250.0, 50.0, -50.0, -10.0 },
555073.354173069, 292.954270581415,
new double[] {
-11.5959274272203, 13.2041866926242,
-0.403417362841545, 0.236771143410386
}), false);
minpackTest(new BrownDennisFunction(20,
new double[] { 2500.0, 500.0, -500.0, -100.0 },
61211252.2338581, 292.954306151134,
new double[] {
-11.5902596937374, 13.2020628854665,
-0.403688070279258, 0.236665033746463
}), false);
}
public void testMinpackChebyquad() {
minpackTest(new ChebyquadFunction(1, 8, 1.0,
1.88623796907732, 1.88623796907732,
new double[] { 0.5 }), false);
minpackTest(new ChebyquadFunction(1, 8, 10.0,
5383344372.34005, 1.88424820499951,
new double[] { 0.9817314924684 }), false);
minpackTest(new ChebyquadFunction(1, 8, 100.0,
0.118088726698392e19, 1.88424820499347,
new double[] { 0.9817314852934 }), false);
minpackTest(new ChebyquadFunction(8, 8, 1.0,
0.196513862833975, 0.0593032355046727,
new double[] {
0.0431536648587336, 0.193091637843267,
0.266328593812698, 0.499999334628884,
0.500000665371116, 0.733671406187302,
0.806908362156733, 0.956846335141266
}), false);
minpackTest(new ChebyquadFunction(9, 9, 1.0,
0.16994993465202, 0.0,
new double[] {
0.0442053461357828, 0.199490672309881,
0.23561910847106, 0.416046907892598,
0.5, 0.583953092107402,
0.764380891528940, 0.800509327690119,
0.955794653864217
}), false);
minpackTest(new ChebyquadFunction(10, 10, 1.0,
0.183747831178711, 0.0806471004038253,
new double[] {
0.0596202671753563, 0.166708783805937,
0.239171018813509, 0.398885290346268,
0.398883667870681, 0.601116332129320,
0.60111470965373, 0.760828981186491,
0.833291216194063, 0.940379732824644
}), false);
}
public void testMinpackBrownAlmostLinear() {
minpackTest(new BrownAlmostLinearFunction(10, 0.5,
16.5302162063499, 0.0,
new double[] {
0.979430303349862, 0.979430303349862,
0.979430303349862, 0.979430303349862,
0.979430303349862, 0.979430303349862,
0.979430303349862, 0.979430303349862,
0.979430303349862, 1.20569696650138
}), false);
minpackTest(new BrownAlmostLinearFunction(10, 5.0,
9765624.00089211, 0.0,
new double[] {
0.979430303349865, 0.979430303349865,
0.979430303349865, 0.979430303349865,
0.979430303349865, 0.979430303349865,
0.979430303349865, 0.979430303349865,
0.979430303349865, 1.20569696650135
}), false);
minpackTest(new BrownAlmostLinearFunction(10, 50.0,
0.9765625e17, 0.0,
new double[] {
1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0
}), false);
minpackTest(new BrownAlmostLinearFunction(30, 0.5,
83.476044467848, 0.0,
new double[] {
0.997754216442807, 0.997754216442807,
0.997754216442807, 0.997754216442807,
0.997754216442807, 0.997754216442807,
0.997754216442807, 0.997754216442807,
0.997754216442807, 0.997754216442807,
0.997754216442807, 0.997754216442807,
0.997754216442807, 0.997754216442807,
0.997754216442807, 0.997754216442807,
0.997754216442807, 0.997754216442807,
0.997754216442807, 0.997754216442807,
0.997754216442807, 0.997754216442807,
0.997754216442807, 0.997754216442807,
0.997754216442807, 0.997754216442807,
0.997754216442807, 0.997754216442807,
0.997754216442807, 1.06737350671578
}), false);
minpackTest(new BrownAlmostLinearFunction(40, 0.5,
128.026364472323, 0.0,
new double[] {
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
1.00000000000002, 1.00000000000002,
0.999999999999121
}), false);
}
public void testMinpackOsborne1() {
minpackTest(new Osborne1Function(new double[] { 0.5, 1.5, -1.0, 0.01, 0.02, },
0.937564021037838, 0.00739249260904843,
new double[] {
0.375410049244025, 1.93584654543108,
-1.46468676748716, 0.0128675339110439,
0.0221227011813076
}), false);
}
public void testMinpackOsborne2() {
minpackTest(new Osborne2Function(new double[] {
1.3, 0.65, 0.65, 0.7, 0.6,
3.0, 5.0, 7.0, 2.0, 4.5, 5.5
},
1.44686540984712, 0.20034404483314,
new double[] {
1.30997663810096, 0.43155248076,
0.633661261602859, 0.599428560991695,
0.754179768272449, 0.904300082378518,
1.36579949521007, 4.82373199748107,
2.39868475104871, 4.56887554791452,
5.67534206273052
}), false);
}
private void minpackTest(MinpackFunction function, boolean exceptionExpected) {
LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
estimator.setMaxCostEval(100 * (function.getN() + 1));
estimator.setCostRelativeTolerance(FastMath.sqrt(2.22044604926e-16));
estimator.setParRelativeTolerance(FastMath.sqrt(2.22044604926e-16));
estimator.setOrthoTolerance(2.22044604926e-16);
assertTrue(function.checkTheoreticalStartCost(estimator.getRMS(function)));
try {
estimator.estimate(function);
assertFalse(exceptionExpected);
} catch (EstimationException lsse) {
assertTrue(exceptionExpected);
}
assertTrue(function.checkTheoreticalMinCost(estimator.getRMS(function)));
assertTrue(function.checkTheoreticalMinParams());
}
private static abstract class MinpackFunction implements EstimationProblem {
protected MinpackFunction(int m,
double[] startParams,
double theoreticalStartCost,
double theoreticalMinCost,
double[] theoreticalMinParams) {
this.m = m;
this.n = startParams.length;
parameters = new EstimatedParameter[n];
for (int i = 0; i < n; ++i) {
parameters[i] = new EstimatedParameter("p" + i, startParams[i]);
}
this.theoreticalStartCost = theoreticalStartCost;
this.theoreticalMinCost = theoreticalMinCost;
this.theoreticalMinParams = theoreticalMinParams;
this.costAccuracy = 1.0e-8;
this.paramsAccuracy = 1.0e-5;
}
protected static double[] buildArray(int n, double x) {
double[] array = new double[n];
Arrays.fill(array, x);
return array;
}
protected void setCostAccuracy(double costAccuracy) {
this.costAccuracy = costAccuracy;
}
protected void setParamsAccuracy(double paramsAccuracy) {
this.paramsAccuracy = paramsAccuracy;
}
public int getN() {
return parameters.length;
}
public boolean checkTheoreticalStartCost(double rms) {
double threshold = costAccuracy * (1.0 + theoreticalStartCost);
return FastMath.abs(FastMath.sqrt(m) * rms - theoreticalStartCost) <= threshold;
}
public boolean checkTheoreticalMinCost(double rms) {
double threshold = costAccuracy * (1.0 + theoreticalMinCost);
return FastMath.abs(FastMath.sqrt(m) * rms - theoreticalMinCost) <= threshold;
}
public boolean checkTheoreticalMinParams() {
if (theoreticalMinParams != null) {
for (int i = 0; i < theoreticalMinParams.length; ++i) {
double mi = theoreticalMinParams[i];
double vi = parameters[i].getEstimate();
if (FastMath.abs(mi - vi) > (paramsAccuracy * (1.0 + FastMath.abs(mi)))) {
return false;
}
}
}
return true;
}
public WeightedMeasurement[] getMeasurements() {
WeightedMeasurement[] measurements = new WeightedMeasurement[m];
for (int i = 0; i < m; ++i) {
measurements[i] = new MinpackMeasurement(this, i);
}
return measurements;
}
public EstimatedParameter[] getUnboundParameters() {
return parameters;
}
public EstimatedParameter[] getAllParameters() {
return parameters;
}
protected abstract double[][] getJacobian();
protected abstract double[] getResiduals();
private static class MinpackMeasurement extends WeightedMeasurement {
public MinpackMeasurement(MinpackFunction f, int index) {
super(1.0, 0.0);
this.index = index;
this.f = f;
}
@Override
public double getTheoreticalValue() {
// this is obviously NOT efficient as we recompute the whole vector
// each time we need only one element, but it is only for test
// purposes and is simpler to check.
// This implementation should NOT be taken as an example, it is ugly!
return f.getResiduals()[index];
}
@Override
public double getPartial(EstimatedParameter parameter) {
// this is obviously NOT efficient as we recompute the whole jacobian
// each time we need only one element, but it is only for test
// purposes and is simpler to check.
// This implementation should NOT be taken as an example, it is ugly!
for (int j = 0; j < f.n; ++j) {
if (parameter == f.parameters[j]) {
return f.getJacobian()[index][j];
}
}
return 0;
}
private int index;
private transient final MinpackFunction f;
private static final long serialVersionUID = 1L;
}
protected int n;
protected int m;
protected EstimatedParameter[] parameters;
protected double theoreticalStartCost;
protected double theoreticalMinCost;
protected double[] theoreticalMinParams;
protected double costAccuracy;
protected double paramsAccuracy;
}
private static class LinearFullRankFunction extends MinpackFunction {
public LinearFullRankFunction(int m, int n, double x0,
double theoreticalStartCost,
double theoreticalMinCost) {
super(m, buildArray(n, x0), theoreticalStartCost,
theoreticalMinCost, buildArray(n, -1.0));
}
@Override
protected double[][] getJacobian() {
double t = 2.0 / m;
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
jacobian[i] = new double[n];
for (int j = 0; j < n; ++j) {
jacobian[i][j] = (i == j) ? (1 - t) : -t;
}
}
return jacobian;
}
@Override
protected double[] getResiduals() {
double sum = 0;
for (int i = 0; i < n; ++i) {
sum += parameters[i].getEstimate();
}
double t = 1 + 2 * sum / m;
double[] f = new double[m];
for (int i = 0; i < n; ++i) {
f[i] = parameters[i].getEstimate() - t;
}
Arrays.fill(f, n, m, -t);
return f;
}
}
private static class LinearRank1Function extends MinpackFunction {
public LinearRank1Function(int m, int n, double x0,
double theoreticalStartCost,
double theoreticalMinCost) {
super(m, buildArray(n, x0), theoreticalStartCost, theoreticalMinCost, null);
}
@Override
protected double[][] getJacobian() {
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
jacobian[i] = new double[n];
for (int j = 0; j < n; ++j) {
jacobian[i][j] = (i + 1) * (j + 1);
}
}
return jacobian;
}
@Override
protected double[] getResiduals() {
double[] f = new double[m];
double sum = 0;
for (int i = 0; i < n; ++i) {
sum += (i + 1) * parameters[i].getEstimate();
}
for (int i = 0; i < m; ++i) {
f[i] = (i + 1) * sum - 1;
}
return f;
}
}
private static class LinearRank1ZeroColsAndRowsFunction extends MinpackFunction {
public LinearRank1ZeroColsAndRowsFunction(int m, int n, double x0) {
super(m, buildArray(n, x0),
FastMath.sqrt(m + (n+1)*(n-2)*(m-2)*(m-1) * ((n+1)*(n-2)*(2*m-3) - 12) / 24.0),
FastMath.sqrt((m * (m + 3) - 6) / (2.0 * (2 * m - 3))),
null);
}
@Override
protected double[][] getJacobian() {
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
jacobian[i] = new double[n];
jacobian[i][0] = 0;
for (int j = 1; j < (n - 1); ++j) {
if (i == 0) {
jacobian[i][j] = 0;
} else if (i != (m - 1)) {
jacobian[i][j] = i * (j + 1);
} else {
jacobian[i][j] = 0;
}
}
jacobian[i][n - 1] = 0;
}
return jacobian;
}
@Override
protected double[] getResiduals() {
double[] f = new double[m];
double sum = 0;
for (int i = 1; i < (n - 1); ++i) {
sum += (i + 1) * parameters[i].getEstimate();
}
for (int i = 0; i < (m - 1); ++i) {
f[i] = i * sum - 1;
}
f[m - 1] = -1;
return f;
}
}
private static class RosenbrockFunction extends MinpackFunction {
public RosenbrockFunction(double[] startParams, double theoreticalStartCost) {
super(2, startParams, theoreticalStartCost, 0.0, buildArray(2, 1.0));
}
@Override
protected double[][] getJacobian() {
double x1 = parameters[0].getEstimate();
return new double[][] { { -20 * x1, 10 }, { -1, 0 } };
}
@Override
protected double[] getResiduals() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
return new double[] { 10 * (x2 - x1 * x1), 1 - x1 };
}
}
private static class HelicalValleyFunction extends MinpackFunction {
public HelicalValleyFunction(double[] startParams,
double theoreticalStartCost) {
super(3, startParams, theoreticalStartCost, 0.0,
new double[] { 1.0, 0.0, 0.0 });
}
@Override
protected double[][] getJacobian() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double tmpSquare = x1 * x1 + x2 * x2;
double tmp1 = twoPi * tmpSquare;
double tmp2 = FastMath.sqrt(tmpSquare);
return new double[][] {
{ 100 * x2 / tmp1, -100 * x1 / tmp1, 10 },
{ 10 * x1 / tmp2, 10 * x2 / tmp2, 0 },
{ 0, 0, 1 }
};
}
@Override
protected double[] getResiduals() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double x3 = parameters[2].getEstimate();
double tmp1;
if (x1 == 0) {
tmp1 = (x2 >= 0) ? 0.25 : -0.25;
} else {
tmp1 = FastMath.atan(x2 / x1) / twoPi;
if (x1 < 0) {
tmp1 += 0.5;
}
}
double tmp2 = FastMath.sqrt(x1 * x1 + x2 * x2);
return new double[] {
10.0 * (x3 - 10 * tmp1),
10.0 * (tmp2 - 1),
x3
};
}
private static final double twoPi = 2.0 * FastMath.PI;
}
private static class PowellSingularFunction extends MinpackFunction {
public PowellSingularFunction(double[] startParams,
double theoreticalStartCost) {
super(4, startParams, theoreticalStartCost, 0.0, buildArray(4, 0.0));
}
@Override
protected double[][] getJacobian() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double x3 = parameters[2].getEstimate();
double x4 = parameters[3].getEstimate();
return new double[][] {
{ 1, 10, 0, 0 },
{ 0, 0, sqrt5, -sqrt5 },
{ 0, 2 * (x2 - 2 * x3), -4 * (x2 - 2 * x3), 0 },
{ 2 * sqrt10 * (x1 - x4), 0, 0, -2 * sqrt10 * (x1 - x4) }
};
}
@Override
protected double[] getResiduals() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double x3 = parameters[2].getEstimate();
double x4 = parameters[3].getEstimate();
return new double[] {
x1 + 10 * x2,
sqrt5 * (x3 - x4),
(x2 - 2 * x3) * (x2 - 2 * x3),
sqrt10 * (x1 - x4) * (x1 - x4)
};
}
private static final double sqrt5 = FastMath.sqrt( 5.0);
private static final double sqrt10 = FastMath.sqrt(10.0);
}
private static class FreudensteinRothFunction extends MinpackFunction {
public FreudensteinRothFunction(double[] startParams,
double theoreticalStartCost,
double theoreticalMinCost,
double[] theoreticalMinParams) {
super(2, startParams, theoreticalStartCost,
theoreticalMinCost, theoreticalMinParams);
}
@Override
protected double[][] getJacobian() {
double x2 = parameters[1].getEstimate();
return new double[][] {
{ 1, x2 * (10 - 3 * x2) - 2 },
{ 1, x2 * ( 2 + 3 * x2) - 14, }
};
}
@Override
protected double[] getResiduals() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
return new double[] {
-13.0 + x1 + ((5.0 - x2) * x2 - 2.0) * x2,
-29.0 + x1 + ((1.0 + x2) * x2 - 14.0) * x2
};
}
}
private static class BardFunction extends MinpackFunction {
public BardFunction(double x0,
double theoreticalStartCost,
double theoreticalMinCost,
double[] theoreticalMinParams) {
super(15, buildArray(3, x0), theoreticalStartCost,
theoreticalMinCost, theoreticalMinParams);
}
@Override
protected double[][] getJacobian() {
double x2 = parameters[1].getEstimate();
double x3 = parameters[2].getEstimate();
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
double tmp1 = i + 1;
double tmp2 = 15 - i;
double tmp3 = (i <= 7) ? tmp1 : tmp2;
double tmp4 = x2 * tmp2 + x3 * tmp3;
tmp4 *= tmp4;
jacobian[i] = new double[] { -1, tmp1 * tmp2 / tmp4, tmp1 * tmp3 / tmp4 };
}
return jacobian;
}
@Override
protected double[] getResiduals() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double x3 = parameters[2].getEstimate();
double[] f = new double[m];
for (int i = 0; i < m; ++i) {
double tmp1 = i + 1;
double tmp2 = 15 - i;
double tmp3 = (i <= 7) ? tmp1 : tmp2;
f[i] = y[i] - (x1 + tmp1 / (x2 * tmp2 + x3 * tmp3));
}
return f;
}
private static final double[] y = {
0.14, 0.18, 0.22, 0.25, 0.29,
0.32, 0.35, 0.39, 0.37, 0.58,
0.73, 0.96, 1.34, 2.10, 4.39
};
}
private static class KowalikOsborneFunction extends MinpackFunction {
public KowalikOsborneFunction(double[] startParams,
double theoreticalStartCost,
double theoreticalMinCost,
double[] theoreticalMinParams) {
super(11, startParams, theoreticalStartCost,
theoreticalMinCost, theoreticalMinParams);
if (theoreticalStartCost > 20.0) {
setCostAccuracy(2.0e-4);
setParamsAccuracy(5.0e-3);
}
}
@Override
protected double[][] getJacobian() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double x3 = parameters[2].getEstimate();
double x4 = parameters[3].getEstimate();
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
double tmp = v[i] * (v[i] + x3) + x4;
double j1 = -v[i] * (v[i] + x2) / tmp;
double j2 = -v[i] * x1 / tmp;
double j3 = j1 * j2;
double j4 = j3 / v[i];
jacobian[i] = new double[] { j1, j2, j3, j4 };
}
return jacobian;
}
@Override
protected double[] getResiduals() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double x3 = parameters[2].getEstimate();
double x4 = parameters[3].getEstimate();
double[] f = new double[m];
for (int i = 0; i < m; ++i) {
f[i] = y[i] - x1 * (v[i] * (v[i] + x2)) / (v[i] * (v[i] + x3) + x4);
}
return f;
}
private static final double[] v = {
4.0, 2.0, 1.0, 0.5, 0.25, 0.167, 0.125, 0.1, 0.0833, 0.0714, 0.0625
};
private static final double[] y = {
0.1957, 0.1947, 0.1735, 0.1600, 0.0844, 0.0627,
0.0456, 0.0342, 0.0323, 0.0235, 0.0246
};
}
private static class MeyerFunction extends MinpackFunction {
public MeyerFunction(double[] startParams,
double theoreticalStartCost,
double theoreticalMinCost,
double[] theoreticalMinParams) {
super(16, startParams, theoreticalStartCost,
theoreticalMinCost, theoreticalMinParams);
if (theoreticalStartCost > 1.0e6) {
setCostAccuracy(7.0e-3);
setParamsAccuracy(2.0e-2);
}
}
@Override
protected double[][] getJacobian() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double x3 = parameters[2].getEstimate();
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
double temp = 5.0 * (i + 1) + 45.0 + x3;
double tmp1 = x2 / temp;
double tmp2 = FastMath.exp(tmp1);
double tmp3 = x1 * tmp2 / temp;
jacobian[i] = new double[] { tmp2, tmp3, -tmp1 * tmp3 };
}
return jacobian;
}
@Override
protected double[] getResiduals() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double x3 = parameters[2].getEstimate();
double[] f = new double[m];
for (int i = 0; i < m; ++i) {
f[i] = x1 * FastMath.exp(x2 / (5.0 * (i + 1) + 45.0 + x3)) - y[i];
}
return f;
}
private static final double[] y = {
34780.0, 28610.0, 23650.0, 19630.0,
16370.0, 13720.0, 11540.0, 9744.0,
8261.0, 7030.0, 6005.0, 5147.0,
4427.0, 3820.0, 3307.0, 2872.0
};
}
private static class WatsonFunction extends MinpackFunction {
public WatsonFunction(int n, double x0,
double theoreticalStartCost,
double theoreticalMinCost,
double[] theoreticalMinParams) {
super(31, buildArray(n, x0), theoreticalStartCost,
theoreticalMinCost, theoreticalMinParams);
}
@Override
protected double[][] getJacobian() {
double[][] jacobian = new double[m][];
for (int i = 0; i < (m - 2); ++i) {
double div = (i + 1) / 29.0;
double s2 = 0.0;
double dx = 1.0;
for (int j = 0; j < n; ++j) {
s2 += dx * parameters[j].getEstimate();
dx *= div;
}
double temp= 2 * div * s2;
dx = 1.0 / div;
jacobian[i] = new double[n];
for (int j = 0; j < n; ++j) {
jacobian[i][j] = dx * (j - temp);
dx *= div;
}
}
jacobian[m - 2] = new double[n];
jacobian[m - 2][0] = 1;
jacobian[m - 1] = new double[n];
jacobian[m - 1][0]= -2 * parameters[0].getEstimate();
jacobian[m - 1][1]= 1;
return jacobian;
}
@Override
protected double[] getResiduals() {
double[] f = new double[m];
for (int i = 0; i < (m - 2); ++i) {
double div = (i + 1) / 29.0;
double s1 = 0;
double dx = 1;
for (int j = 1; j < n; ++j) {
s1 += j * dx * parameters[j].getEstimate();
dx *= div;
}
double s2 =0;
dx =1;
for (int j = 0; j < n; ++j) {
s2 += dx * parameters[j].getEstimate();
dx *= div;
}
f[i] = s1 - s2 * s2 - 1;
}
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
f[m - 2] = x1;
f[m - 1] = x2 - x1 * x1 - 1;
return f;
}
}
private static class Box3DimensionalFunction extends MinpackFunction {
public Box3DimensionalFunction(int m, double[] startParams,
double theoreticalStartCost) {
super(m, startParams, theoreticalStartCost,
0.0, new double[] { 1.0, 10.0, 1.0 });
}
@Override
protected double[][] getJacobian() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
double tmp = (i + 1) / 10.0;
jacobian[i] = new double[] {
-tmp * FastMath.exp(-tmp * x1),
tmp * FastMath.exp(-tmp * x2),
FastMath.exp(-i - 1) - FastMath.exp(-tmp)
};
}
return jacobian;
}
@Override
protected double[] getResiduals() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double x3 = parameters[2].getEstimate();
double[] f = new double[m];
for (int i = 0; i < m; ++i) {
double tmp = (i + 1) / 10.0;
f[i] = FastMath.exp(-tmp * x1) - FastMath.exp(-tmp * x2)
+ (FastMath.exp(-i - 1) - FastMath.exp(-tmp)) * x3;
}
return f;
}
}
private static class JennrichSampsonFunction extends MinpackFunction {
public JennrichSampsonFunction(int m, double[] startParams,
double theoreticalStartCost,
double theoreticalMinCost,
double[] theoreticalMinParams) {
super(m, startParams, theoreticalStartCost,
theoreticalMinCost, theoreticalMinParams);
}
@Override
protected double[][] getJacobian() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
double t = i + 1;
jacobian[i] = new double[] { -t * FastMath.exp(t * x1), -t * FastMath.exp(t * x2) };
}
return jacobian;
}
@Override
protected double[] getResiduals() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double[] f = new double[m];
for (int i = 0; i < m; ++i) {
double temp = i + 1;
f[i] = 2 + 2 * temp - FastMath.exp(temp * x1) - FastMath.exp(temp * x2);
}
return f;
}
}
private static class BrownDennisFunction extends MinpackFunction {
public BrownDennisFunction(int m, double[] startParams,
double theoreticalStartCost,
double theoreticalMinCost,
double[] theoreticalMinParams) {
super(m, startParams, theoreticalStartCost,
theoreticalMinCost, theoreticalMinParams);
setCostAccuracy(2.5e-8);
}
@Override
protected double[][] getJacobian() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double x3 = parameters[2].getEstimate();
double x4 = parameters[3].getEstimate();
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
double temp = (i + 1) / 5.0;
double ti = FastMath.sin(temp);
double tmp1 = x1 + temp * x2 - FastMath.exp(temp);
double tmp2 = x3 + ti * x4 - FastMath.cos(temp);
jacobian[i] = new double[] {
2 * tmp1, 2 * temp * tmp1, 2 * tmp2, 2 * ti * tmp2
};
}
return jacobian;
}
@Override
protected double[] getResiduals() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double x3 = parameters[2].getEstimate();
double x4 = parameters[3].getEstimate();
double[] f = new double[m];
for (int i = 0; i < m; ++i) {
double temp = (i + 1) / 5.0;
double tmp1 = x1 + temp * x2 - FastMath.exp(temp);
double tmp2 = x3 + FastMath.sin(temp) * x4 - FastMath.cos(temp);
f[i] = tmp1 * tmp1 + tmp2 * tmp2;
}
return f;
}
}
private static class ChebyquadFunction extends MinpackFunction {
private static double[] buildChebyquadArray(int n, double factor) {
double[] array = new double[n];
double inv = factor / (n + 1);
for (int i = 0; i < n; ++i) {
array[i] = (i + 1) * inv;
}
return array;
}
public ChebyquadFunction(int n, int m, double factor,
double theoreticalStartCost,
double theoreticalMinCost,
double[] theoreticalMinParams) {
super(m, buildChebyquadArray(n, factor), theoreticalStartCost,
theoreticalMinCost, theoreticalMinParams);
}
@Override
protected double[][] getJacobian() {
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
jacobian[i] = new double[n];
}
double dx = 1.0 / n;
for (int j = 0; j < n; ++j) {
double tmp1 = 1;
double tmp2 = 2 * parameters[j].getEstimate() - 1;
double temp = 2 * tmp2;
double tmp3 = 0;
double tmp4 = 2;
for (int i = 0; i < m; ++i) {
jacobian[i][j] = dx * tmp4;
double ti = 4 * tmp2 + temp * tmp4 - tmp3;
tmp3 = tmp4;
tmp4 = ti;
ti = temp * tmp2 - tmp1;
tmp1 = tmp2;
tmp2 = ti;
}
}
return jacobian;
}
@Override
protected double[] getResiduals() {
double[] f = new double[m];
for (int j = 0; j < n; ++j) {
double tmp1 = 1;
double tmp2 = 2 * parameters[j].getEstimate() - 1;
double temp = 2 * tmp2;
for (int i = 0; i < m; ++i) {
f[i] += tmp2;
double ti = temp * tmp2 - tmp1;
tmp1 = tmp2;
tmp2 = ti;
}
}
double dx = 1.0 / n;
boolean iev = false;
for (int i = 0; i < m; ++i) {
f[i] *= dx;
if (iev) {
f[i] += 1.0 / (i * (i + 2));
}
iev = ! iev;
}
return f;
}
}
private static class BrownAlmostLinearFunction extends MinpackFunction {
public BrownAlmostLinearFunction(int m, double factor,
double theoreticalStartCost,
double theoreticalMinCost,
double[] theoreticalMinParams) {
super(m, buildArray(m, factor), theoreticalStartCost,
theoreticalMinCost, theoreticalMinParams);
}
@Override
protected double[][] getJacobian() {
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
jacobian[i] = new double[n];
}
double prod = 1;
for (int j = 0; j < n; ++j) {
prod *= parameters[j].getEstimate();
for (int i = 0; i < n; ++i) {
jacobian[i][j] = 1;
}
jacobian[j][j] = 2;
}
for (int j = 0; j < n; ++j) {
EstimatedParameter vj = parameters[j];
double temp = vj.getEstimate();
if (temp == 0) {
temp = 1;
prod = 1;
for (int k = 0; k < n; ++k) {
if (k != j) {
prod *= parameters[k].getEstimate();
}
}
}
jacobian[n - 1][j] = prod / temp;
}
return jacobian;
}
@Override
protected double[] getResiduals() {
double[] f = new double[m];
double sum = -(n + 1);
double prod = 1;
for (int j = 0; j < n; ++j) {
sum += parameters[j].getEstimate();
prod *= parameters[j].getEstimate();
}
for (int i = 0; i < n; ++i) {
f[i] = parameters[i].getEstimate() + sum;
}
f[n - 1] = prod - 1;
return f;
}
}
private static class Osborne1Function extends MinpackFunction {
public Osborne1Function(double[] startParams,
double theoreticalStartCost,
double theoreticalMinCost,
double[] theoreticalMinParams) {
super(33, startParams, theoreticalStartCost,
theoreticalMinCost, theoreticalMinParams);
}
@Override
protected double[][] getJacobian() {
double x2 = parameters[1].getEstimate();
double x3 = parameters[2].getEstimate();
double x4 = parameters[3].getEstimate();
double x5 = parameters[4].getEstimate();
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
double temp = 10.0 * i;
double tmp1 = FastMath.exp(-temp * x4);
double tmp2 = FastMath.exp(-temp * x5);
jacobian[i] = new double[] {
-1, -tmp1, -tmp2, temp * x2 * tmp1, temp * x3 * tmp2
};
}
return jacobian;
}
@Override
protected double[] getResiduals() {
double x1 = parameters[0].getEstimate();
double x2 = parameters[1].getEstimate();
double x3 = parameters[2].getEstimate();
double x4 = parameters[3].getEstimate();
double x5 = parameters[4].getEstimate();
double[] f = new double[m];
for (int i = 0; i < m; ++i) {
double temp = 10.0 * i;
double tmp1 = FastMath.exp(-temp * x4);
double tmp2 = FastMath.exp(-temp * x5);
f[i] = y[i] - (x1 + x2 * tmp1 + x3 * tmp2);
}
return f;
}
private static final double[] y = {
0.844, 0.908, 0.932, 0.936, 0.925, 0.908, 0.881, 0.850, 0.818, 0.784, 0.751,
0.718, 0.685, 0.658, 0.628, 0.603, 0.580, 0.558, 0.538, 0.522, 0.506, 0.490,
0.478, 0.467, 0.457, 0.448, 0.438, 0.431, 0.424, 0.420, 0.414, 0.411, 0.406
};
}
private static class Osborne2Function extends MinpackFunction {
public Osborne2Function(double[] startParams,
double theoreticalStartCost,
double theoreticalMinCost,
double[] theoreticalMinParams) {
super(65, startParams, theoreticalStartCost,
theoreticalMinCost, theoreticalMinParams);
}
@Override
protected double[][] getJacobian() {
double x01 = parameters[0].getEstimate();
double x02 = parameters[1].getEstimate();
double x03 = parameters[2].getEstimate();
double x04 = parameters[3].getEstimate();
double x05 = parameters[4].getEstimate();
double x06 = parameters[5].getEstimate();
double x07 = parameters[6].getEstimate();
double x08 = parameters[7].getEstimate();
double x09 = parameters[8].getEstimate();
double x10 = parameters[9].getEstimate();
double x11 = parameters[10].getEstimate();
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
double temp = i / 10.0;
double tmp1 = FastMath.exp(-x05 * temp);
double tmp2 = FastMath.exp(-x06 * (temp - x09) * (temp - x09));
double tmp3 = FastMath.exp(-x07 * (temp - x10) * (temp - x10));
double tmp4 = FastMath.exp(-x08 * (temp - x11) * (temp - x11));
jacobian[i] = new double[] {
-tmp1,
-tmp2,
-tmp3,
-tmp4,
temp * x01 * tmp1,
x02 * (temp - x09) * (temp - x09) * tmp2,
x03 * (temp - x10) * (temp - x10) * tmp3,
x04 * (temp - x11) * (temp - x11) * tmp4,
-2 * x02 * x06 * (temp - x09) * tmp2,
-2 * x03 * x07 * (temp - x10) * tmp3,
-2 * x04 * x08 * (temp - x11) * tmp4
};
}
return jacobian;
}
@Override
protected double[] getResiduals() {
double x01 = parameters[0].getEstimate();
double x02 = parameters[1].getEstimate();
double x03 = parameters[2].getEstimate();
double x04 = parameters[3].getEstimate();
double x05 = parameters[4].getEstimate();
double x06 = parameters[5].getEstimate();
double x07 = parameters[6].getEstimate();
double x08 = parameters[7].getEstimate();
double x09 = parameters[8].getEstimate();
double x10 = parameters[9].getEstimate();
double x11 = parameters[10].getEstimate();
double[] f = new double[m];
for (int i = 0; i < m; ++i) {
double temp = i / 10.0;
double tmp1 = FastMath.exp(-x05 * temp);
double tmp2 = FastMath.exp(-x06 * (temp - x09) * (temp - x09));
double tmp3 = FastMath.exp(-x07 * (temp - x10) * (temp - x10));
double tmp4 = FastMath.exp(-x08 * (temp - x11) * (temp - x11));
f[i] = y[i] - (x01 * tmp1 + x02 * tmp2 + x03 * tmp3 + x04 * tmp4);
}
return f;
}
private static final double[] y = {
1.366, 1.191, 1.112, 1.013, 0.991,
0.885, 0.831, 0.847, 0.786, 0.725,
0.746, 0.679, 0.608, 0.655, 0.616,
0.606, 0.602, 0.626, 0.651, 0.724,
0.649, 0.649, 0.694, 0.644, 0.624,
0.661, 0.612, 0.558, 0.533, 0.495,
0.500, 0.423, 0.395, 0.375, 0.372,
0.391, 0.396, 0.405, 0.428, 0.429,
0.523, 0.562, 0.607, 0.653, 0.672,
0.708, 0.633, 0.668, 0.645, 0.632,
0.591, 0.559, 0.597, 0.625, 0.739,
0.710, 0.729, 0.720, 0.636, 0.581,
0.428, 0.292, 0.162, 0.098, 0.054
};
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/estimation/EstimatedParameterTest.java 100644 1750 1750 4126 11532241243 32037 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.estimation;
import org.apache.commons.math.estimation.EstimatedParameter;
import org.apache.commons.math.util.FastMath;
import junit.framework.*;
@Deprecated
public class EstimatedParameterTest
extends TestCase {
public EstimatedParameterTest(String name) {
super(name);
}
public void testConstruction() {
EstimatedParameter p1 = new EstimatedParameter("p1", 1.0);
assertTrue(p1.getName().equals("p1"));
checkValue(p1.getEstimate(), 1.0);
assertTrue(! p1.isBound());
EstimatedParameter p2 = new EstimatedParameter("p2", 2.0, true);
assertTrue(p2.getName().equals("p2"));
checkValue(p2.getEstimate(), 2.0);
assertTrue(p2.isBound());
}
public void testBound() {
EstimatedParameter p = new EstimatedParameter("p", 0.0);
assertTrue(! p.isBound());
p.setBound(true);
assertTrue(p.isBound());
p.setBound(false);
assertTrue(! p.isBound());
}
public void testEstimate() {
EstimatedParameter p = new EstimatedParameter("p", 0.0);
checkValue(p.getEstimate(), 0.0);
for (double e = 0.0; e < 10.0; e += 0.5) {
p.setEstimate(e);
checkValue(p.getEstimate(), e);
}
}
private void checkValue(double value, double expected) {
assertTrue(FastMath.abs(value - expected) < 1.0e-10);
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/ConvergenceExceptionTest.java 100644 1750 1750 6157 11532241244 30227 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math;
import junit.framework.TestCase;
import java.util.Locale;
import org.apache.commons.math.exception.util.LocalizedFormats;
/**
* @version $Revision: 1035475 $ $Date: 2010-11-15 23:39:25 +0100 (lun. 15 nov. 2010) $
*/
public class ConvergenceExceptionTest extends TestCase {
public void testConstructor(){
ConvergenceException ex = new ConvergenceException();
assertNull(ex.getCause());
assertNotNull(ex.getMessage());
assertNotNull(ex.getMessage(Locale.FRENCH));
assertFalse(ex.getMessage().equals(ex.getMessage(Locale.FRENCH)));
}
public void testConstructorPatternArguments(){
LocalizedFormats pattern = LocalizedFormats.ROTATION_MATRIX_DIMENSIONS;
Object[] arguments = { Integer.valueOf(6), Integer.valueOf(4) };
ConvergenceException ex = new ConvergenceException(pattern, arguments);
assertNull(ex.getCause());
assertEquals(pattern, ex.getGeneralPattern());
assertEquals(arguments.length, ex.getArguments().length);
for (int i = 0; i < arguments.length; ++i) {
assertEquals(arguments[i], ex.getArguments()[i]);
}
assertFalse(pattern.equals(ex.getMessage()));
assertFalse(ex.getMessage().equals(ex.getMessage(Locale.FRENCH)));
}
public void testConstructorCause(){
String inMsg = "inner message";
Exception cause = new Exception(inMsg);
ConvergenceException ex = new ConvergenceException(cause);
assertEquals(cause, ex.getCause());
}
public void testConstructorPatternArgumentsCause(){
LocalizedFormats pattern = LocalizedFormats.ROTATION_MATRIX_DIMENSIONS;
Object[] arguments = { Integer.valueOf(6), Integer.valueOf(4) };
String inMsg = "inner message";
Exception cause = new Exception(inMsg);
ConvergenceException ex = new ConvergenceException(cause, pattern, arguments);
assertEquals(cause, ex.getCause());
assertEquals(pattern, ex.getGeneralPattern());
assertEquals(arguments.length, ex.getArguments().length);
for (int i = 0; i < arguments.length; ++i) {
assertEquals(arguments[i], ex.getArguments()[i]);
}
assertFalse(pattern.equals(ex.getMessage()));
assertFalse(ex.getMessage().equals(ex.getMessage(Locale.FRENCH)));
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/random/ValueServerTest.java 100644 1750 1750 15206 11532241241 27645 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.random;
import java.io.EOFException;
import java.net.URL;
import org.apache.commons.math.RetryTestCase;
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
/**
* Test cases for the ValueServer class.
*
* @version $Revision: 1003907 $ $Date: 2010-10-03 00:23:34 +0200 (dim. 03 oct. 2010) $
*/
public final class ValueServerTest extends RetryTestCase {
private ValueServer vs = new ValueServer();
public ValueServerTest(String name) {
super(name);
}
@Override
public void setUp() {
vs.setMode(ValueServer.DIGEST_MODE);
URL url = getClass().getResource("testData.txt");
vs.setValuesFileURL(url);
}
/**
* Generate 1000 random values and make sure they look OK.
* Note that there is a non-zero (but very small) probability that
* these tests will fail even if the code is working as designed.
*/
public void testNextDigest() throws Exception{
double next = 0.0;
double tolerance = 0.1;
vs.computeDistribution();
assertTrue("empirical distribution property",
vs.getEmpiricalDistribution() != null);
SummaryStatistics stats = new SummaryStatistics();
for (int i = 1; i < 1000; i++) {
next = vs.getNext();
stats.addValue(next);
}
assertEquals("mean", 5.069831575018909, stats.getMean(), tolerance);
assertEquals
("std dev", 1.0173699343977738, stats.getStandardDeviation(),
tolerance);
vs.computeDistribution(500);
stats = new SummaryStatistics();
for (int i = 1; i < 1000; i++) {
next = vs.getNext();
stats.addValue(next);
}
assertEquals("mean", 5.069831575018909, stats.getMean(), tolerance);
assertEquals
("std dev", 1.0173699343977738, stats.getStandardDeviation(),
tolerance);
}
/**
* Make sure exception thrown if digest getNext is attempted
* before loading empiricalDistribution.
*/
public void testNextDigestFail() throws Exception {
try {
vs.getNext();
fail("Expecting IllegalStateException");
} catch (IllegalStateException ex) {}
}
public void testEmptyReplayFile() throws Exception {
try {
URL url = getClass().getResource("emptyFile.txt");
vs.setMode(ValueServer.REPLAY_MODE);
vs.setValuesFileURL(url);
vs.getNext();
fail("an exception should have been thrown");
} catch (EOFException eof) {
// expected behavior
}
}
public void testEmptyDigestFile() throws Exception {
try {
URL url = getClass().getResource("emptyFile.txt");
vs.setMode(ValueServer.DIGEST_MODE);
vs.setValuesFileURL(url);
vs.computeDistribution();
fail("an exception should have been thrown");
} catch (EOFException eof) {
// expected behavior
}
}
/**
* Test ValueServer REPLAY_MODE using values in testData file.
* Check that the values 1,2,1001,1002 match data file values 1 and 2.
* the sample data file.
*/
public void testReplay() throws Exception {
double firstDataValue = 4.038625496201205;
double secondDataValue = 3.6485326248346936;
double tolerance = 10E-15;
double compareValue = 0.0d;
vs.setMode(ValueServer.REPLAY_MODE);
vs.resetReplayFile();
compareValue = vs.getNext();
assertEquals(compareValue,firstDataValue,tolerance);
compareValue = vs.getNext();
assertEquals(compareValue,secondDataValue,tolerance);
for (int i = 3; i < 1001; i++) {
compareValue = vs.getNext();
}
compareValue = vs.getNext();
assertEquals(compareValue,firstDataValue,tolerance);
compareValue = vs.getNext();
assertEquals(compareValue,secondDataValue,tolerance);
vs.closeReplayFile();
// make sure no NPE
vs.closeReplayFile();
}
/**
* Test other ValueServer modes
*/
public void testModes() throws Exception {
vs.setMode(ValueServer.CONSTANT_MODE);
vs.setMu(0);
assertEquals("constant mode test",vs.getMu(),vs.getNext(),Double.MIN_VALUE);
vs.setMode(ValueServer.UNIFORM_MODE);
vs.setMu(2);
double val = vs.getNext();
assertTrue(val > 0 && val < 4);
vs.setSigma(1);
vs.setMode(ValueServer.GAUSSIAN_MODE);
val = vs.getNext();
assertTrue("gaussian value close enough to mean",
val < vs.getMu() + 100*vs.getSigma());
vs.setMode(ValueServer.EXPONENTIAL_MODE);
val = vs.getNext();
assertTrue(val > 0);
try {
vs.setMode(1000);
vs.getNext();
fail("bad mode, expecting IllegalStateException");
} catch (IllegalStateException ex) {
// ignored
}
}
/**
* Test fill
*/
public void testFill() throws Exception {
vs.setMode(ValueServer.CONSTANT_MODE);
vs.setMu(2);
double[] val = new double[5];
vs.fill(val);
for (int i = 0; i < 5; i++) {
assertEquals("fill test in place",2,val[i],Double.MIN_VALUE);
}
double v2[] = vs.fill(3);
for (int i = 0; i < 3; i++) {
assertEquals("fill test in place",2,v2[i],Double.MIN_VALUE);
}
}
/**
* Test getters to make Clover happy
*/
public void testProperties() throws Exception {
vs.setMode(ValueServer.CONSTANT_MODE);
assertEquals("mode test",ValueServer.CONSTANT_MODE,vs.getMode());
vs.setValuesFileURL("http://www.apache.org");
URL url = vs.getValuesFileURL();
assertEquals("valuesFileURL test","http://www.apache.org",url.toString());
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/random/MersenneTwisterTest.java 100644 1750 1750 101324 11532241241 30555 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.random;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
import org.apache.commons.math.util.FastMath;
import org.junit.Test;
public class MersenneTwisterTest {
@Test
public void testGaussian() {
MersenneTwister mt = new MersenneTwister(42853252100l);
SummaryStatistics sample = new SummaryStatistics();
for (int i = 0; i < 1000; ++i) {
sample.addValue(mt.nextGaussian());
}
assertEquals(0.0, sample.getMean(), 0.005);
assertEquals(1.0, sample.getStandardDeviation(), 0.025);
}
@Test
public void testDouble() {
MersenneTwister mt = new MersenneTwister(195357343514l);
SummaryStatistics sample = new SummaryStatistics();
for (int i = 0; i < 1000; ++i) {
sample.addValue(mt.nextDouble());
}
assertEquals(0.5, sample.getMean(), 0.02);
assertEquals(1.0 / (2.0 * FastMath.sqrt(3.0)),
sample.getStandardDeviation(),
0.002);
}
@Test
public void testFloat() {
MersenneTwister mt = new MersenneTwister(4442733263l);
SummaryStatistics sample = new SummaryStatistics();
for (int i = 0; i < 1000; ++i) {
sample.addValue(mt.nextFloat());
}
assertEquals(0.5, sample.getMean(), 0.01);
assertEquals(1.0 / (2.0 * FastMath.sqrt(3.0)),
sample.getStandardDeviation(),
0.006);
}
@Test(expected=java.lang.IllegalArgumentException.class)
public void testNextIntNeg() {
new MersenneTwister(1).nextInt(-1);
}
@Test
public void testNextIntN() {
MersenneTwister mt = new MersenneTwister(0x12b8a7412bb25el);
for (int n = 1; n < 20; ++n) {
int[] count = new int[n];
for (int k = 0; k < 10000; ++k) {
int l = mt.nextInt(n);
++count[l];
assertTrue(l >= 0);
assertTrue(l < n);
}
for (int i = 0; i < n; ++i) {
assertTrue(n * count[i] > 8600);
assertTrue(n * count[i] < 11200);
}
}
}
@Test
public void testNextInt() {
MersenneTwister mt = new MersenneTwister(new int[] { 1, 2, 3, 4, 5 });
int walk = 0;
for (int k = 0; k < 10000; ++k) {
if (mt.nextInt() >= 0) {
++walk;
} else {
--walk;
}
}
assertTrue(FastMath.abs(walk) < 120);
}
@Test
public void testNextLong() {
MersenneTwister mt = new MersenneTwister(12345);
int walk = 0;
for (int k = 0; k < 10000; ++k) {
if (mt.nextLong() >= 0) {
++walk;
} else {
--walk;
}
}
assertTrue(FastMath.abs(walk) < 50);
}
@Test
public void testNexBoolean() {
MersenneTwister mt = new MersenneTwister(76342);
int walk = 0;
for (int k = 0; k < 10000; ++k) {
if (mt.nextBoolean()) {
++walk;
} else {
--walk;
}
}
assertTrue(FastMath.abs(walk) < 250);
}
@Test
public void testNexBytes() {
MersenneTwister mt = new MersenneTwister(0);
int[] count = new int[256];
byte[] bytes = new byte[10];
for (int k = 0; k < 100000; ++k) {
mt.nextBytes(bytes);
for (byte b : bytes) {
++count[b + 128];
}
}
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
for (int c : count) {
min = FastMath.min(min, c);
max = FastMath.max(max, c);
}
int expected = (100000 * bytes.length) / count.length;
assertTrue((expected - 200) < min);
assertTrue(max < (expected + 200));
}
@Test
public void testMakotoNishimura() {
MersenneTwister mt = new MersenneTwister(new int[] {0x123, 0x234, 0x345, 0x456});
long[] refInt = {
1067595299l, 955945823l, 477289528l, 4107218783l, 4228976476l, 3344332714l, 3355579695l, 227628506l,
810200273l, 2591290167l, 2560260675l, 3242736208l, 646746669l, 1479517882l, 4245472273l, 1143372638l,
3863670494l, 3221021970l, 1773610557l, 1138697238l, 1421897700l, 1269916527l, 2859934041l, 1764463362l,
3874892047l, 3965319921l, 72549643l, 2383988930l, 2600218693l, 3237492380l, 2792901476l, 725331109l,
605841842l, 271258942l, 715137098l, 3297999536l, 1322965544l, 4229579109l, 1395091102l, 3735697720l,
2101727825l, 3730287744l, 2950434330l, 1661921839l, 2895579582l, 2370511479l, 1004092106l, 2247096681l,
2111242379l, 3237345263l, 4082424759l, 219785033l, 2454039889l, 3709582971l, 835606218l, 2411949883l,
2735205030l, 756421180l, 2175209704l, 1873865952l, 2762534237l, 4161807854l, 3351099340l, 181129879l,
3269891896l, 776029799l, 2218161979l, 3001745796l, 1866825872l, 2133627728l, 34862734l, 1191934573l,
3102311354l, 2916517763l, 1012402762l, 2184831317l, 4257399449l, 2899497138l, 3818095062l, 3030756734l,
1282161629l, 420003642l, 2326421477l, 2741455717l, 1278020671l, 3744179621l, 271777016l, 2626330018l,
2560563991l, 3055977700l, 4233527566l, 1228397661l, 3595579322l, 1077915006l, 2395931898l, 1851927286l,
3013683506l, 1999971931l, 3006888962l, 1049781534l, 1488758959l, 3491776230l, 104418065l, 2448267297l,
3075614115l, 3872332600l, 891912190l, 3936547759l, 2269180963l, 2633455084l, 1047636807l, 2604612377l,
2709305729l, 1952216715l, 207593580l, 2849898034l, 670771757l, 2210471108l, 467711165l, 263046873l,
3569667915l, 1042291111l, 3863517079l, 1464270005l, 2758321352l, 3790799816l, 2301278724l, 3106281430l,
7974801l, 2792461636l, 555991332l, 621766759l, 1322453093l, 853629228l, 686962251l, 1455120532l,
957753161l, 1802033300l, 1021534190l, 3486047311l, 1902128914l, 3701138056l, 4176424663l, 1795608698l,
560858864l, 3737752754l, 3141170998l, 1553553385l, 3367807274l, 711546358l, 2475125503l, 262969859l,
251416325l, 2980076994l, 1806565895l, 969527843l, 3529327173l, 2736343040l, 2987196734l, 1649016367l,
2206175811l, 3048174801l, 3662503553l, 3138851612l, 2660143804l, 1663017612l, 1816683231l, 411916003l,
3887461314l, 2347044079l, 1015311755l, 1203592432l, 2170947766l, 2569420716l, 813872093l, 1105387678l,
1431142475l, 220570551l, 4243632715l, 4179591855l, 2607469131l, 3090613241l, 282341803l, 1734241730l,
1391822177l, 1001254810l, 827927915l, 1886687171l, 3935097347l, 2631788714l, 3905163266l, 110554195l,
2447955646l, 3717202975l, 3304793075l, 3739614479l, 3059127468l, 953919171l, 2590123714l, 1132511021l,
3795593679l, 2788030429l, 982155079l, 3472349556l, 859942552l, 2681007391l, 2299624053l, 647443547l,
233600422l, 608168955l, 3689327453l, 1849778220l, 1608438222l, 3968158357l, 2692977776l, 2851872572l,
246750393l, 3582818628l, 3329652309l, 4036366910l, 1012970930l, 950780808l, 3959768744l, 2538550045l,
191422718l, 2658142375l, 3276369011l, 2927737484l, 1234200027l, 1920815603l, 3536074689l, 1535612501l,
2184142071l, 3276955054l, 428488088l, 2378411984l, 4059769550l, 3913744741l, 2732139246l, 64369859l,
3755670074l, 842839565l, 2819894466l, 2414718973l, 1010060670l, 1839715346l, 2410311136l, 152774329l,
3485009480l, 4102101512l, 2852724304l, 879944024l, 1785007662l, 2748284463l, 1354768064l, 3267784736l,
2269127717l, 3001240761l, 3179796763l, 895723219l, 865924942l, 4291570937l, 89355264l, 1471026971l,
4114180745l, 3201939751l, 2867476999l, 2460866060l, 3603874571l, 2238880432l, 3308416168l, 2072246611l,
2755653839l, 3773737248l, 1709066580l, 4282731467l, 2746170170l, 2832568330l, 433439009l, 3175778732l,
26248366l, 2551382801l, 183214346l, 3893339516l, 1928168445l, 1337157619l, 3429096554l, 3275170900l,
1782047316l, 4264403756l, 1876594403l, 4289659572l, 3223834894l, 1728705513l, 4068244734l, 2867840287l,
1147798696l, 302879820l, 1730407747l, 1923824407l, 1180597908l, 1569786639l, 198796327l, 560793173l,
2107345620l, 2705990316l, 3448772106l, 3678374155l, 758635715l, 884524671l, 486356516l, 1774865603l,
3881226226l, 2635213607l, 1181121587l, 1508809820l, 3178988241l, 1594193633l, 1235154121l, 326117244l,
2304031425l, 937054774l, 2687415945l, 3192389340l, 2003740439l, 1823766188l, 2759543402l, 10067710l,
1533252662l, 4132494984l, 82378136l, 420615890l, 3467563163l, 541562091l, 3535949864l, 2277319197l,
3330822853l, 3215654174l, 4113831979l, 4204996991l, 2162248333l, 3255093522l, 2219088909l, 2978279037l,
255818579l, 2859348628l, 3097280311l, 2569721123l, 1861951120l, 2907080079l, 2719467166l, 998319094l,
2521935127l, 2404125338l, 259456032l, 2086860995l, 1839848496l, 1893547357l, 2527997525l, 1489393124l,
2860855349l, 76448234l, 2264934035l, 744914583l, 2586791259l, 1385380501l, 66529922l, 1819103258l,
1899300332l, 2098173828l, 1793831094l, 276463159l, 360132945l, 4178212058l, 595015228l, 177071838l,
2800080290l, 1573557746l, 1548998935l, 378454223l, 1460534296l, 1116274283l, 3112385063l, 3709761796l,
827999348l, 3580042847l, 1913901014l, 614021289l, 4278528023l, 1905177404l, 45407939l, 3298183234l,
1184848810l, 3644926330l, 3923635459l, 1627046213l, 3677876759l, 969772772l, 1160524753l, 1522441192l,
452369933l, 1527502551l, 832490847l, 1003299676l, 1071381111l, 2891255476l, 973747308l, 4086897108l,
1847554542l, 3895651598l, 2227820339l, 1621250941l, 2881344691l, 3583565821l, 3510404498l, 849362119l,
862871471l, 797858058l, 2867774932l, 2821282612l, 3272403146l, 3997979905l, 209178708l, 1805135652l,
6783381l, 2823361423l, 792580494l, 4263749770l, 776439581l, 3798193823l, 2853444094l, 2729507474l,
1071873341l, 1329010206l, 1289336450l, 3327680758l, 2011491779l, 80157208l, 922428856l, 1158943220l,
1667230961l, 2461022820l, 2608845159l, 387516115l, 3345351910l, 1495629111l, 4098154157l, 3156649613l,
3525698599l, 4134908037l, 446713264l, 2137537399l, 3617403512l, 813966752l, 1157943946l, 3734692965l,
1680301658l, 3180398473l, 3509854711l, 2228114612l, 1008102291l, 486805123l, 863791847l, 3189125290l,
1050308116l, 3777341526l, 4291726501l, 844061465l, 1347461791l, 2826481581l, 745465012l, 2055805750l,
4260209475l, 2386693097l, 2980646741l, 447229436l, 2077782664l, 1232942813l, 4023002732l, 1399011509l,
3140569849l, 2579909222l, 3794857471l, 900758066l, 2887199683l, 1720257997l, 3367494931l, 2668921229l,
955539029l, 3818726432l, 1105704962l, 3889207255l, 2277369307l, 2746484505l, 1761846513l, 2413916784l,
2685127085l, 4240257943l, 1166726899l, 4215215715l, 3082092067l, 3960461946l, 1663304043l, 2087473241l,
4162589986l, 2507310778l, 1579665506l, 767234210l, 970676017l, 492207530l, 1441679602l, 1314785090l,
3262202570l, 3417091742l, 1561989210l, 3011406780l, 1146609202l, 3262321040l, 1374872171l, 1634688712l,
1280458888l, 2230023982l, 419323804l, 3262899800l, 39783310l, 1641619040l, 1700368658l, 2207946628l,
2571300939l, 2424079766l, 780290914l, 2715195096l, 3390957695l, 163151474l, 2309534542l, 1860018424l,
555755123l, 280320104l, 1604831083l, 2713022383l, 1728987441l, 3639955502l, 623065489l, 3828630947l,
4275479050l, 3516347383l, 2343951195l, 2430677756l, 635534992l, 3868699749l, 808442435l, 3070644069l,
4282166003l, 2093181383l, 2023555632l, 1568662086l, 3422372620l, 4134522350l, 3016979543l, 3259320234l,
2888030729l, 3185253876l, 4258779643l, 1267304371l, 1022517473l, 815943045l, 929020012l, 2995251018l,
3371283296l, 3608029049l, 2018485115l, 122123397l, 2810669150l, 1411365618l, 1238391329l, 1186786476l,
3155969091l, 2242941310l, 1765554882l, 279121160l, 4279838515l, 1641578514l, 3796324015l, 13351065l,
103516986l, 1609694427l, 551411743l, 2493771609l, 1316337047l, 3932650856l, 4189700203l, 463397996l,
2937735066l, 1855616529l, 2626847990l, 55091862l, 3823351211l, 753448970l, 4045045500l, 1274127772l,
1124182256l, 92039808l, 2126345552l, 425973257l, 386287896l, 2589870191l, 1987762798l, 4084826973l,
2172456685l, 3366583455l, 3602966653l, 2378803535l, 2901764433l, 3716929006l, 3710159000l, 2653449155l,
3469742630l, 3096444476l, 3932564653l, 2595257433l, 318974657l, 3146202484l, 853571438l, 144400272l,
3768408841l, 782634401l, 2161109003l, 570039522l, 1886241521l, 14249488l, 2230804228l, 1604941699l,
3928713335l, 3921942509l, 2155806892l, 134366254l, 430507376l, 1924011722l, 276713377l, 196481886l,
3614810992l, 1610021185l, 1785757066l, 851346168l, 3761148643l, 2918835642l, 3364422385l, 3012284466l,
3735958851l, 2643153892l, 3778608231l, 1164289832l, 205853021l, 2876112231l, 3503398282l, 3078397001l,
3472037921l, 1748894853l, 2740861475l, 316056182l, 1660426908l, 168885906l, 956005527l, 3984354789l,
566521563l, 1001109523l, 1216710575l, 2952284757l, 3834433081l, 3842608301l, 2467352408l, 3974441264l,
3256601745l, 1409353924l, 1329904859l, 2307560293l, 3125217879l, 3622920184l, 3832785684l, 3882365951l,
2308537115l, 2659155028l, 1450441945l, 3532257603l, 3186324194l, 1225603425l, 1124246549l, 175808705l,
3009142319l, 2796710159l, 3651990107l, 160762750l, 1902254979l, 1698648476l, 1134980669l, 497144426l,
3302689335l, 4057485630l, 3603530763l, 4087252587l, 427812652l, 286876201l, 823134128l, 1627554964l,
3745564327l, 2589226092l, 4202024494l, 62878473l, 3275585894l, 3987124064l, 2791777159l, 1916869511l,
2585861905l, 1375038919l, 1403421920l, 60249114l, 3811870450l, 3021498009l, 2612993202l, 528933105l,
2757361321l, 3341402964l, 2621861700l, 273128190l, 4015252178l, 3094781002l, 1621621288l, 2337611177l,
1796718448l, 1258965619l, 4241913140l, 2138560392l, 3022190223l, 4174180924l, 450094611l, 3274724580l,
617150026l, 2704660665l, 1469700689l, 1341616587l, 356715071l, 1188789960l, 2278869135l, 1766569160l,
2795896635l, 57824704l, 2893496380l, 1235723989l, 1630694347l, 3927960522l, 428891364l, 1814070806l,
2287999787l, 4125941184l, 3968103889l, 3548724050l, 1025597707l, 1404281500l, 2002212197l, 92429143l,
2313943944l, 2403086080l, 3006180634l, 3561981764l, 1671860914l, 1768520622l, 1803542985l, 844848113l,
3006139921l, 1410888995l, 1157749833l, 2125704913l, 1789979528l, 1799263423l, 741157179l, 2405862309l,
767040434l, 2655241390l, 3663420179l, 2172009096l, 2511931187l, 1680542666l, 231857466l, 1154981000l,
157168255l, 1454112128l, 3505872099l, 1929775046l, 2309422350l, 2143329496l, 2960716902l, 407610648l,
2938108129l, 2581749599l, 538837155l, 2342628867l, 430543915l, 740188568l, 1937713272l, 3315215132l,
2085587024l, 4030765687l, 766054429l, 3517641839l, 689721775l, 1294158986l, 1753287754l, 4202601348l,
1974852792l, 33459103l, 3568087535l, 3144677435l, 1686130825l, 4134943013l, 3005738435l, 3599293386l,
426570142l, 754104406l, 3660892564l, 1964545167l, 829466833l, 821587464l, 1746693036l, 1006492428l,
1595312919l, 1256599985l, 1024482560l, 1897312280l, 2902903201l, 691790057l, 1037515867l, 3176831208l,
1968401055l, 2173506824l, 1089055278l, 1748401123l, 2941380082l, 968412354l, 1818753861l, 2973200866l,
3875951774l, 1119354008l, 3988604139l, 1647155589l, 2232450826l, 3486058011l, 3655784043l, 3759258462l,
847163678l, 1082052057l, 989516446l, 2871541755l, 3196311070l, 3929963078l, 658187585l, 3664944641l,
2175149170l, 2203709147l, 2756014689l, 2456473919l, 3890267390l, 1293787864l, 2830347984l, 3059280931l,
4158802520l, 1561677400l, 2586570938l, 783570352l, 1355506163l, 31495586l, 3789437343l, 3340549429l,
2092501630l, 896419368l, 671715824l, 3530450081l, 3603554138l, 1055991716l, 3442308219l, 1499434728l,
3130288473l, 3639507000l, 17769680l, 2259741420l, 487032199l, 4227143402l, 3693771256l, 1880482820l,
3924810796l, 381462353l, 4017855991l, 2452034943l, 2736680833l, 2209866385l, 2128986379l, 437874044l,
595759426l, 641721026l, 1636065708l, 3899136933l, 629879088l, 3591174506l, 351984326l, 2638783544l,
2348444281l, 2341604660l, 2123933692l, 143443325l, 1525942256l, 364660499l, 599149312l, 939093251l,
1523003209l, 106601097l, 376589484l, 1346282236l, 1297387043l, 764598052l, 3741218111l, 933457002l,
1886424424l, 3219631016l, 525405256l, 3014235619l, 323149677l, 2038881721l, 4100129043l, 2851715101l,
2984028078l, 1888574695l, 2014194741l, 3515193880l, 4180573530l, 3461824363l, 2641995497l, 3179230245l,
2902294983l, 2217320456l, 4040852155l, 1784656905l, 3311906931l, 87498458l, 2752971818l, 2635474297l,
2831215366l, 3682231106l, 2920043893l, 3772929704l, 2816374944l, 309949752l, 2383758854l, 154870719l,
385111597l, 1191604312l, 1840700563l, 872191186l, 2925548701l, 1310412747l, 2102066999l, 1504727249l,
3574298750l, 1191230036l, 3330575266l, 3180292097l, 3539347721l, 681369118l, 3305125752l, 3648233597l,
950049240l, 4173257693l, 1760124957l, 512151405l, 681175196l, 580563018l, 1169662867l, 4015033554l,
2687781101l, 699691603l, 2673494188l, 1137221356l, 123599888l, 472658308l, 1053598179l, 1012713758l,
3481064843l, 3759461013l, 3981457956l, 3830587662l, 1877191791l, 3650996736l, 988064871l, 3515461600l,
4089077232l, 2225147448l, 1249609188l, 2643151863l, 3896204135l, 2416995901l, 1397735321l, 3460025646l
};
double[] refDouble = {
0.76275443, 0.99000644, 0.98670464, 0.10143112, 0.27933125, 0.69867227, 0.94218740, 0.03427201,
0.78842173, 0.28180608, 0.92179002, 0.20785655, 0.54534773, 0.69644020, 0.38107718, 0.23978165,
0.65286910, 0.07514568, 0.22765211, 0.94872929, 0.74557914, 0.62664415, 0.54708246, 0.90959343,
0.42043116, 0.86334511, 0.19189126, 0.14718544, 0.70259889, 0.63426346, 0.77408121, 0.04531601,
0.04605807, 0.88595519, 0.69398270, 0.05377184, 0.61711170, 0.05565708, 0.10133577, 0.41500776,
0.91810699, 0.22320679, 0.23353705, 0.92871862, 0.98897234, 0.19786706, 0.80558809, 0.06961067,
0.55840445, 0.90479405, 0.63288060, 0.95009721, 0.54948447, 0.20645042, 0.45000959, 0.87050869,
0.70806991, 0.19406895, 0.79286390, 0.49332866, 0.78483914, 0.75145146, 0.12341941, 0.42030252,
0.16728160, 0.59906494, 0.37575460, 0.97815160, 0.39815952, 0.43595080, 0.04952478, 0.33917805,
0.76509902, 0.61034321, 0.90654701, 0.92915732, 0.85365931, 0.18812377, 0.65913428, 0.28814566,
0.59476081, 0.27835931, 0.60722542, 0.68310435, 0.69387186, 0.03699800, 0.65897714, 0.17527003,
0.02889304, 0.86777366, 0.12352068, 0.91439461, 0.32022990, 0.44445731, 0.34903686, 0.74639273,
0.65918367, 0.92492794, 0.31872642, 0.77749724, 0.85413832, 0.76385624, 0.32744211, 0.91326300,
0.27458185, 0.22190155, 0.19865383, 0.31227402, 0.85321225, 0.84243342, 0.78544200, 0.71854080,
0.92503892, 0.82703064, 0.88306297, 0.47284073, 0.70059042, 0.48003761, 0.38671694, 0.60465770,
0.41747204, 0.47163243, 0.72750808, 0.65830223, 0.10955369, 0.64215401, 0.23456345, 0.95944940,
0.72822249, 0.40888451, 0.69980355, 0.26677428, 0.57333635, 0.39791582, 0.85377858, 0.76962816,
0.72004885, 0.90903087, 0.51376506, 0.37732665, 0.12691640, 0.71249738, 0.81217908, 0.37037313,
0.32772374, 0.14238259, 0.05614811, 0.74363008, 0.39773267, 0.94859135, 0.31452454, 0.11730313,
0.62962618, 0.33334237, 0.45547255, 0.10089665, 0.56550662, 0.60539371, 0.16027624, 0.13245301,
0.60959939, 0.04671662, 0.99356286, 0.57660859, 0.40269560, 0.45274629, 0.06699735, 0.85064246,
0.87742744, 0.54508392, 0.87242982, 0.29321385, 0.67660627, 0.68230715, 0.79052073, 0.48592054,
0.25186266, 0.93769755, 0.28565487, 0.47219067, 0.99054882, 0.13155240, 0.47110470, 0.98556600,
0.84397623, 0.12875246, 0.90953202, 0.49129015, 0.23792727, 0.79481194, 0.44337770, 0.96564297,
0.67749118, 0.55684872, 0.27286897, 0.79538393, 0.61965356, 0.22487929, 0.02226018, 0.49248200,
0.42247006, 0.91797788, 0.99250134, 0.23449967, 0.52531508, 0.10246337, 0.78685622, 0.34310922,
0.89892996, 0.40454552, 0.68608407, 0.30752487, 0.83601319, 0.54956031, 0.63777550, 0.82199797,
0.24890696, 0.48801123, 0.48661910, 0.51223987, 0.32969635, 0.31075073, 0.21393155, 0.73453207,
0.15565705, 0.58584522, 0.28976728, 0.97621478, 0.61498701, 0.23891470, 0.28518540, 0.46809591,
0.18371914, 0.37597910, 0.13492176, 0.66849449, 0.82811466, 0.56240330, 0.37548956, 0.27562998,
0.27521910, 0.74096121, 0.77176757, 0.13748143, 0.99747138, 0.92504502, 0.09175241, 0.21389176,
0.21766512, 0.31183245, 0.23271221, 0.21207367, 0.57903312, 0.77523344, 0.13242613, 0.31037988,
0.01204835, 0.71652949, 0.84487594, 0.14982178, 0.57423142, 0.45677888, 0.48420169, 0.53465428,
0.52667473, 0.46880526, 0.49849733, 0.05670710, 0.79022476, 0.03872047, 0.21697212, 0.20443086,
0.28949326, 0.81678186, 0.87629474, 0.92297064, 0.27373097, 0.84625273, 0.51505586, 0.00582792,
0.33295971, 0.91848412, 0.92537226, 0.91760033, 0.07541125, 0.71745848, 0.61158698, 0.00941650,
0.03135554, 0.71527471, 0.24821915, 0.63636652, 0.86159918, 0.26450229, 0.60160194, 0.35557725,
0.24477500, 0.07186456, 0.51757096, 0.62120362, 0.97981062, 0.69954667, 0.21065616, 0.13382753,
0.27693186, 0.59644095, 0.71500764, 0.04110751, 0.95730081, 0.91600724, 0.47704678, 0.26183479,
0.34706971, 0.07545431, 0.29398385, 0.93236070, 0.60486023, 0.48015011, 0.08870451, 0.45548581,
0.91872718, 0.38142712, 0.10668643, 0.01397541, 0.04520355, 0.93822273, 0.18011940, 0.57577277,
0.91427606, 0.30911399, 0.95853475, 0.23611214, 0.69619891, 0.69601980, 0.76765372, 0.58515930,
0.49479057, 0.11288752, 0.97187699, 0.32095365, 0.57563608, 0.40760618, 0.78703383, 0.43261152,
0.90877651, 0.84686346, 0.10599030, 0.72872803, 0.19315490, 0.66152912, 0.10210518, 0.06257876,
0.47950688, 0.47062066, 0.72701157, 0.48915116, 0.66110261, 0.60170685, 0.24516994, 0.12726050,
0.03451185, 0.90864994, 0.83494878, 0.94800035, 0.91035206, 0.14480751, 0.88458997, 0.53498312,
0.15963215, 0.55378627, 0.35171349, 0.28719791, 0.09097957, 0.00667896, 0.32309622, 0.87561479,
0.42534520, 0.91748977, 0.73908457, 0.41793223, 0.99279792, 0.87908370, 0.28458072, 0.59132853,
0.98672190, 0.28547393, 0.09452165, 0.89910674, 0.53681109, 0.37931425, 0.62683489, 0.56609740,
0.24801549, 0.52948179, 0.98328855, 0.66403523, 0.55523786, 0.75886666, 0.84784685, 0.86829981,
0.71448906, 0.84670080, 0.43922919, 0.20771016, 0.64157936, 0.25664246, 0.73055695, 0.86395782,
0.65852932, 0.99061803, 0.40280575, 0.39146298, 0.07291005, 0.97200603, 0.20555729, 0.59616495,
0.08138254, 0.45796388, 0.33681125, 0.33989127, 0.18717090, 0.53545811, 0.60550838, 0.86520709,
0.34290701, 0.72743276, 0.73023855, 0.34195926, 0.65019733, 0.02765254, 0.72575740, 0.32709576,
0.03420866, 0.26061893, 0.56997511, 0.28439072, 0.84422744, 0.77637570, 0.55982168, 0.06720327,
0.58449067, 0.71657369, 0.15819609, 0.58042821, 0.07947911, 0.40193792, 0.11376012, 0.88762938,
0.67532159, 0.71223735, 0.27829114, 0.04806073, 0.21144026, 0.58830274, 0.04140071, 0.43215628,
0.12952729, 0.94668759, 0.87391019, 0.98382450, 0.27750768, 0.90849647, 0.90962737, 0.59269720,
0.96102026, 0.49544979, 0.32007095, 0.62585546, 0.03119821, 0.85953001, 0.22017528, 0.05834068,
0.80731217, 0.53799961, 0.74166948, 0.77426600, 0.43938444, 0.54862081, 0.58575513, 0.15886492,
0.73214332, 0.11649057, 0.77463977, 0.85788827, 0.17061997, 0.66838056, 0.96076133, 0.07949296,
0.68521946, 0.89986254, 0.05667410, 0.12741385, 0.83470977, 0.63969104, 0.46612929, 0.10200126,
0.01194925, 0.10476340, 0.90285217, 0.31221221, 0.32980614, 0.46041971, 0.52024973, 0.05425470,
0.28330912, 0.60426543, 0.00598243, 0.97244013, 0.21135841, 0.78561597, 0.78428734, 0.63422849,
0.32909934, 0.44771136, 0.27380750, 0.14966697, 0.18156268, 0.65686758, 0.28726350, 0.97074787,
0.63676171, 0.96649494, 0.24526295, 0.08297372, 0.54257548, 0.03166785, 0.33735355, 0.15946671,
0.02102971, 0.46228045, 0.11892296, 0.33408336, 0.29875681, 0.29847692, 0.73767569, 0.02080745,
0.62980060, 0.08082293, 0.22993106, 0.25031439, 0.87787525, 0.45150053, 0.13673441, 0.63407612,
0.97907688, 0.52241942, 0.50580158, 0.06273902, 0.05270283, 0.77031811, 0.05113352, 0.24393329,
0.75036441, 0.37436336, 0.22877652, 0.59975358, 0.85707591, 0.88691457, 0.85547165, 0.36641027,
0.58720133, 0.45462835, 0.09243817, 0.32981586, 0.07820411, 0.25421519, 0.36004706, 0.60092307,
0.46192412, 0.36758683, 0.98424170, 0.08019934, 0.68594024, 0.45826386, 0.29962317, 0.79365413,
0.89231296, 0.49478547, 0.87645944, 0.23590734, 0.28106737, 0.75026285, 0.08136314, 0.79582424,
0.76010628, 0.82792971, 0.27947652, 0.72482861, 0.82191216, 0.46171689, 0.79189752, 0.96043686,
0.51609668, 0.88995725, 0.28998963, 0.55191845, 0.03934737, 0.83033700, 0.49553013, 0.98009549,
0.19017594, 0.98347750, 0.33452066, 0.87144372, 0.72106301, 0.71272114, 0.71465963, 0.88361677,
0.85571283, 0.73782329, 0.20920458, 0.34855153, 0.46766817, 0.02780062, 0.74898344, 0.03680650,
0.44866557, 0.77426312, 0.91025891, 0.25195236, 0.87319953, 0.63265037, 0.25552148, 0.27422476,
0.95217406, 0.39281839, 0.66441573, 0.09158900, 0.94515992, 0.07800798, 0.02507888, 0.39901462,
0.17382573, 0.12141278, 0.85502334, 0.19902911, 0.02160210, 0.44460522, 0.14688742, 0.68020336,
0.71323733, 0.60922473, 0.95400380, 0.99611159, 0.90897777, 0.41073520, 0.66206647, 0.32064685,
0.62805003, 0.50677209, 0.52690101, 0.87473387, 0.73918362, 0.39826974, 0.43683919, 0.80459118,
0.32422684, 0.01958019, 0.95319576, 0.98326137, 0.83931735, 0.69060863, 0.33671416, 0.68062550,
0.65152380, 0.33392969, 0.03451730, 0.95227244, 0.68200635, 0.85074171, 0.64721009, 0.51234433,
0.73402047, 0.00969637, 0.93835057, 0.80803854, 0.31485260, 0.20089527, 0.01323282, 0.59933780,
0.31584602, 0.20209563, 0.33754800, 0.68604181, 0.24443049, 0.19952227, 0.78162632, 0.10336988,
0.11360736, 0.23536740, 0.23262256, 0.67803776, 0.48749791, 0.74658435, 0.92156640, 0.56706407,
0.36683221, 0.99157136, 0.23421374, 0.45183767, 0.91609720, 0.85573315, 0.37706276, 0.77042618,
0.30891908, 0.40709595, 0.06944866, 0.61342849, 0.88817388, 0.58734506, 0.98711323, 0.14744128,
0.63242656, 0.87704136, 0.68347125, 0.84446569, 0.43265239, 0.25146321, 0.04130111, 0.34259839,
0.92697368, 0.40878778, 0.56990338, 0.76204273, 0.19820348, 0.66314909, 0.02482844, 0.06669207,
0.50205581, 0.26084093, 0.65139159, 0.41650223, 0.09733904, 0.56344203, 0.62651696, 0.67332139,
0.58037374, 0.47258086, 0.21010758, 0.05713135, 0.89390629, 0.10781246, 0.32037450, 0.07628388,
0.34227964, 0.42190597, 0.58201860, 0.77363549, 0.49595133, 0.86031236, 0.83906769, 0.81098161,
0.26694195, 0.14215941, 0.88210306, 0.53634237, 0.12090720, 0.82480459, 0.75930318, 0.31847147,
0.92768077, 0.01037616, 0.56201727, 0.88107122, 0.35925856, 0.85860762, 0.61109408, 0.70408301,
0.58434977, 0.92192494, 0.62667915, 0.75988365, 0.06858761, 0.36156496, 0.58057195, 0.13636150,
0.57719713, 0.59340255, 0.63530602, 0.22976282, 0.71915530, 0.41162531, 0.63979565, 0.09931342,
0.79344045, 0.10893790, 0.84450224, 0.23122236, 0.99485593, 0.73637397, 0.17276368, 0.13357764,
0.74965804, 0.64991737, 0.61990341, 0.41523170, 0.05878239, 0.05687301, 0.05497131, 0.42868366,
0.42571090, 0.25810502, 0.89642955, 0.30439758, 0.39310223, 0.11357431, 0.04288255, 0.23397550,
0.11200634, 0.85621396, 0.89733974, 0.37508865, 0.42077265, 0.68597384, 0.72781399, 0.19296476,
0.61699087, 0.31667128, 0.67756410, 0.00177323, 0.05725176, 0.79474693, 0.18885238, 0.06724856,
0.68193156, 0.42202167, 0.22082041, 0.28554673, 0.64995708, 0.87851940, 0.29124547, 0.61009521,
0.87374537, 0.05743712, 0.69902994, 0.81925115, 0.45653873, 0.37236821, 0.31118709, 0.52734307,
0.39672836, 0.38185294, 0.30163915, 0.17374510, 0.04913278, 0.90404879, 0.25742801, 0.58266467,
0.97663209, 0.79823377, 0.36437958, 0.15206043, 0.26529938, 0.22690047, 0.05839021, 0.84721160,
0.18622435, 0.37809403, 0.55706977, 0.49828704, 0.47659049, 0.24289680, 0.88477595, 0.07807463,
0.56245739, 0.73490635, 0.21099431, 0.13164942, 0.75840044, 0.66877037, 0.28988183, 0.44046090,
0.24967434, 0.80048356, 0.26029740, 0.30416821, 0.64151867, 0.52067892, 0.12880774, 0.85465381,
0.02690525, 0.19149288, 0.49630295, 0.79682619, 0.43566145, 0.00288078, 0.81484193, 0.03763639,
0.68529083, 0.01339574, 0.38405386, 0.30537067, 0.22994703, 0.44000045, 0.27217985, 0.53831243,
0.02870435, 0.86282045, 0.61831306, 0.09164956, 0.25609707, 0.07445781, 0.72185784, 0.90058883,
0.30070608, 0.94476583, 0.56822213, 0.21933909, 0.96772793, 0.80063440, 0.26307906, 0.31183306,
0.16501252, 0.55436179, 0.68562285, 0.23829083, 0.86511559, 0.57868991, 0.81888344, 0.20126869,
0.93172350, 0.66028129, 0.21786948, 0.78515828, 0.10262106, 0.35390326, 0.79303876, 0.63427924,
0.90479631, 0.31024934, 0.60635447, 0.56198079, 0.63573813, 0.91854197, 0.99701497, 0.83085849,
0.31692291, 0.01925964, 0.97446405, 0.98751283, 0.60944293, 0.13751018, 0.69519957, 0.68956636,
0.56969015, 0.46440193, 0.88341765, 0.36754434, 0.89223647, 0.39786427, 0.85055280, 0.12749961,
0.79452122, 0.89449784, 0.14567830, 0.45716830, 0.74822309, 0.28200437, 0.42546044, 0.17464886,
0.68308746, 0.65496587, 0.52935411, 0.12736159, 0.61523955, 0.81590528, 0.63107864, 0.39786553,
0.20102294, 0.53292914, 0.75485590, 0.59847044, 0.32861691, 0.12125866, 0.58917183, 0.07638293,
0.86845380, 0.29192617, 0.03989733, 0.52180460, 0.32503407, 0.64071852, 0.69516575, 0.74254998,
0.54587026, 0.48713246, 0.32920155, 0.08719954, 0.63497059, 0.54328459, 0.64178757, 0.45583809,
0.70694291, 0.85212760, 0.86074305, 0.33163422, 0.85739792, 0.59908488, 0.74566046, 0.72157152
};
for (int i = 0; i < refInt.length; ++i) {
int r = mt.nextInt();
assertEquals(refInt[i], (r & 0x7fffffffl) | ((r < 0) ? 0x80000000l : 0x0l));
}
for (int i = 0; i < refDouble.length; ++i) {
int r = mt.nextInt();
assertEquals(refDouble[i],
((r & 0x7fffffffl) | ((r < 0) ? 0x80000000l : 0x0l)) / 4294967296.0,
1.0e-8);
}
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/random/Well19937aTest.java 100644 1750 1750 40636 11532241241 27070 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.random;
import org.junit.Assert;
import org.junit.Test;
public class Well19937aTest {
@Test
public void testReferenceCode() {
int[] base = {
740849862, 1202665156, -199039369, -259008301, -291878969, -1164428990, -1565918811, 491009864,
-1883086670, 1383450241, 1244617256, 689006653, -1576746370, -1307940314, 1421489086, 1742094000,
-595495729, 1047766204, 1875773301, -1637793284, 1379017098, 262792705, 191880010, -251000180,
-1753047622, -972355720, 90626881, 1644693418, 1503365577, 439653419, 1806361562, 1268823869
};
int[] init = new int[624];
for (int i = 0; i < init.length; ++i) {
init[i] = base[i % base.length] + i;
}
Well19937a mt = new Well19937a(init);
int[] refInt = {
-612874471, -354976292, -1838197125, -1781560577, 278390997, 1214938280, -1752615390, -760835246, -1712883765, -241205782, -145390202, 495649160, -514388259, -1271015916, -1640000013, 849273623,
-549729394, -1206917255, -545909692, 811925434, -1665729633, -1525292882, 1416246482, -153220826, 1148868872, -326143196, 1724979062, 1790931148, -1648679618, -439051683, 112482777, -1484051520,
-1881272572, -1270447031, -1216102401, 1579107248, -1224395621, 2144411988, -416216641, -1529222361, 1628987080, 164445245, 1506928916, 928145916, 1436000427, 862025970, 560077705, -1887251027,
-514360858, 1735094506, 475624879, 1755802355, 295448361, -155399225, 3972415, 1368201076, -465126094, -1622687259, -246099304, 1798631152, -1937269102, -1700560396, -293352622, -896632303,
-2088933220, -194382452, -480218162, -1618517785, -1925031481, -150217434, 1678937261, 2130832364, -485546678, -1499224981, 1430390884, -1895417302, 210514746, 1781140999, -1940853105, -1238099647,
485922557, -103223212, 633481679, -632946979, 695235541, -1661735272, 277603567, -958341538, 256982285, 1850270018, -327388076, -219053874, 1380560653, -1221689980, 1335863752, -545032383,
-575291735, -1295623907, -140058298, 1063302709, -1290702617, -790401546, -170630961, -1203114473, 1458063108, -1212753301, 1546428514, 2112636413, -1463028928, -1812598032, -883529486, 1131084094,
62042165, 2135819802, -1192342739, 98361522, -1341042205, -475283063, -1632033747, 1745196892, 168608689, -914987039, 274428907, -881357258, 167940012, -1975737532, -903960486, -1370984244,
-589352935, 1783633514, -570111010, 71495377, 194463285, -1243905021, -1398490898, 221691209, -55728834, -638916786, -770622372, -1911651810, -295233027, 301467998, 2058638784, 681490183,
-1547865078, -1668135684, 1299261826, 1649468635, 287995017, -2076844852, 1193468826, -853948258, 120082777, 1051829542, -1288514343, -159456430, 275748820, -480127107, -604943233, -2138088332,
1202614819, 1427201263, -1906344469, -1230779533, 1690367192, 733159097, 794410312, -1114452505, -1601554413, 976747949, 1517787154, 2091780205, 1052078906, 1919282771, -191013374, 1805397142,
736939268, -1056272823, -727464316, -659459005, 797803875, -1104633884, 1042342081, -24514837, 1919469940, 1903722546, -814157872, 1605407665, -262351256, -288949635, 729204844, -1132605534,
745453338, 387915035, 1094173337, 2100279147, 156863702, -257377544, -719587984, -1496015613, 1908993744, 2016957554, 918749666, -135963651, -1356808639, -1711185741, 1472589240, -398100149,
628791415, -1381837652, -1820702771, -593586943, -1456631279, -1837975351, -1394249972, -556916726, 833231177, 43449750, 1029237092, -2086437337, -459463076, -533031784, -1739648287, -1374722961,
2024908394, 1389678488, 2018558, -1391707864, -795935743, 904816957, 836583280, 1766194531, -1374431014, -904437876, 2030248636, -265724199, 2056758426, -810499837, 887193593, -77811488,
1496312336, -1874348275, -456193866, -2137130942, 868120387, 29025455, -1999867716, 2001322335, -579152815, -390892056, 1592011837, -306394879, 93636886, -190879994, 1923358153, 269052141,
-396050253, -987531729, 480350991, 1276744541, -1445571957, -957571005, -2046270221, -1715395752, 1113585628, -1782113514, -697560146, 835320000, 1014320959, -2119834109, 460056841, -1464772991,
-1282790418, -2120806165, 86176097, -731086307, 832497517, -1876684928, 541008240, 551124479, -450919132, 647860281, -2115397586, 979247589, 1095559204, 1927958688, 169497703, 1999579054,
2019745038, 1656022059, -1109662138, 375237154, 1450814436, 919988416, 849761266, 1457057327, 1771166577, -1639880487, -852488298, 1767063646, 657295386, -585561879, 740792583, 1664558308,
-654749506, 1109275990, 182597559, 1106789745, -1806628480, 25948116, 1748374299, 196057325, -164213209, 1687024594, 782029276, 1879737947, -1528219611, 412585737, 1190325629, 1985821911,
-1272945202, -1238637137, 465818730, -1537670961, 1131953615, 905623579, 609183424, 1138422991, 1522974699, 589719061, -1310894604, 890952933, -885204790, -393535694, 1238408670, 1780660354,
677803525, -1121509064, 1553148616, 1109165936, -1450120385, 1525252521, -1354897489, -595402189, -1274551767, -869281409, 1788815975, 2020262116, 1124100185, -400839020, 310574108, 1354413045,
-1310514485, 1895732085, 626639054, 1667355357, 2065637178, -1889009143, -440157749, 1762849463, -1693853642, -56602956, -930874188, -398470740, 778356402, -2113156881, 42854964, 1844399604,
-2098310302, -1812029757, 1441188713, 899579267, 1266994172, 1841370863, -660740252, -43254718, 1124500192, 1884907320, 879997211, 1775139845, -1360112721, 1630490057, 362567879, 1113475029,
290319279, -1209506867, 398146039, -957742350, 1185761854, 1519676447, -912689915, -1117128973, -305563462, -1928033363, -1766324543, 1702753492, 1696951912, -1895072395, 932663591, -566548128,
991675996, 56529814, 980735023, 718166662, -650028466, -886842051, 1857048587, -569023569, -1820572202, -851452711, -958700452, -621825633, -65649888, -510143183, 761267599, -1692108035,
1729071710, 1623630864, -53498654, 267235687, 659201413, 1152882627, -824194574, 356636960, -502391121, -538453360, 66115376, -1633290370, -1522088932, 268949070, 684499443, -859474501,
1586764345, -1515639709, 319695602, -307025150, 69076508, 1050726785, -1340930110, 552191600, -207852941, -273572993, -539580440, 710343120, 1957076127, -1107172811, -561518280, -1775022699,
1978792904, 1935531451, -2084046304, -419742902, -737652926, 614022023, 1676952428, 769892939, -1092786807, -1117113223, -266029995, -350150999, 207738542, 1964896575, 48805284, 1736500159,
551289617, -1847923501, 1856609505, 2007480480, -681860219, -1198106493, 1483591043, -523895316, -1814473078, -1521087404, -1348859926, 1298056897, 1813789478, 946683654, 79196400, 1766250931,
472737685, 1764634332, -1844726079, -130619045, -508713868, -1762537125, 1010108863, 170107098, 1705386380, -1139681802, 183739097, 1662699401, 1842694501, 1714633805, 46208876, 616720693,
-252553427, 1986302230, -103130254, 1943225981, 110746655, 553260552, 1588938073, -1934623163, -2144781332, -2086217416, 1941265852, -781953226, 1216234254, 605543697, -710872598, 2048636577,
-1986927728, -1007017623, 1243051501, -614249563, -2128221291, 581579813, 1173464240, -1906830937, 261329601, -1805974103, 769823490, 1858731164, -561762071, 516417430, -1221329437, -825500715,
1091364656, -993658663, -1475434188, -1070804384, -1876492082, 899494424, 683486936, 878807455, 56642807, -1268202879, 1379172046, -1386869373, -1158233876, 1759190552, 1597629789, 1411151497,
-1254268471, 1075936979, -918778269, -2132675184, 953140888, 1906982077, 1154200766, -365384600, -1142488826, 708535121, -2134869964, -1531201665, -2100526761, 1268256467, 2071480803, 193135243,
1374158182, 989505347, -933612202, -2134839213, -1302795271, -2092029041, 1812014826, 2090855917, 2005348528, 606434393, -60141386, 11156360, 539516285, -122485034, -893237911, -978127424,
1509901816, -451029719, 428544700, -1622965963, -1993611605, -1989324583, 1104111587, -795138585, -899552401, -2110167769, -234502445, 1586963605, -503778455, 529261062, 325327284, -106186403,
65369563, -1475700698, -228624261, 715975009, 1099352363, -1796883396, 1376542700, -308942420, -344940451, -395389249, -1562737166, 1869802677, 1273494710, 2075587668, -789570273, 1563347596,
1142901755, 1676422422, -1729157809, -1399423717, -1814262429, -1809707284, 1393992342, -570246212, 1065528749, -781643849, 1218667301, -1097949471, 1305629790, 901301039, -704762030, 360582612,
1411910672, 1848068741, -614500891, -146889637, -913903597, 723527277, -147033328, -199273155, 734997691, -2072735286, 2129258691, -1385074104, 931616624, 1065477319, -1543474555, -531410292,
-2123119121, -1538464113, -1153585193, 1559931968, -654877011, 879865200, 1489681397, 1998864644, -1964160144, 163671782, -858364148, -323324233, 801208648, 705864113, 436184243, 643773864,
2087594507, 134637265, -749956494, -1657343972, -1828172168, -27357303, -1145161336, -1192513644, 216148260, 611393153, -13752671, -358631090, -1211920749, 593572064, 657629904, -1445961088,
-250704995, 1797542707, -2122311891, -316774825, -296303057, -868002056, -86697533, 2020588145, 1203427903, -1371839056, 669531557, -2031033836, 1323994690, 13703036, 785437772, -1465821554,
-694756014, -2131068154, -1745448876, -1095891733, 936594025, -1119068454, 855423970, 1705079340, -905640608, 162297141, 1336619311, -344353769, -92608588, -1080573824, 2002293105, -2088030765,
-1684198727, -129054718, -949437132, -127983221, -216664110, 1700146143, -711174649, 1500113839, 1212236226, -2017364219, -1263597675, 511929344, -323998524, -2021313185, 1803000924, 927670608,
336267187, 1244256964, -1665390108, 991395134, -251232188, 1267445783, 1547951569, 740269916, 1776431169, 1687220659, 228229817, 271386089, -682906779, -438090344, 1190436796, -744272540,
1879221151, 1145200306, -1730983338, -1119209309, 90826726, 1567861540, 1638852830, -1645384932, 1566909531, 1088584561, 1030555565, -1872052014, 720320695, -885053674, -321216789, 739907579,
368580703, -443635520, 1232705619, -1355949988, -1047211249, -1571429448, 599299852, 1036970439, 1513838571, -51797291, -26647565, -1262878942, -916262582, 1579082269, -292007383, 1289013866,
-1612184284, 1451738668, 448608569, 476432992, -1229609565, 786372409, 929928149, -150100614, 448155944, -1322320576, -856549627, 1057443268, -1536809554, 577508258, 584906122, 275295163,
-604262071, -236043234, -1866434954, -2072447013, 646132876, 847562546, -310005953, -1104162658, 393261203, -730102354, 440824482, 1654535035, -1296359745, 1487359328, -977776604, -775827779,
-1298695106, 519080622, 1697162240, 227873031, -371123123, 1273702312, -1710063656, -2138342344, 1139555478, 1531578907, -1498880699, 1183507362, 1875307493, -1649740413, 2135386504, -962458407,
424161768, 504272962, 202204247, 1783466420, 2015579232, -676642965, 2067456450, 914480415, -620398841, 1880405399, 1406637142, 1951104977, 633496157, 224861869, -58659291, 994942775,
-479000645, 1421449115, 100168104, 249754169, -1219011494, 1736303638, 364013694, -1750035055, -479217141, 1652913106, -2109452331, 1633842910, -1547663337, 936627493, -1152799743, 896955899,
-1407742850, -523769014, 357161414, 872293304, 744895980, 720829676, -240843156, -111779524, 1292836315, -1792141538, 1946959925, 1181751089, -1120674052, 1185192575, -1387002557, 1973209255,
-120887476, -766577735, -443913073, 786620227, 428564781, -101232106, -425959852, 198082021, 1173272226, -1744840378, -1621135606, -1539498583, -1101274572, 43399711, -1256764602, 1201920787,
2049426139, 846545551, -2121520873, -1202939675, -470425740, 321987390, 1862019060, -951540342, -894238318, -430407175, -1662746491, 656574776, 1580373777, -431290218, 1645824323, -1953526979,
-374682356, 474291752, 1071558425, 511038981, -760598678, -567797285, -1176476266, -268409005, -2130644484, -67970563, 1756046948, 1429860462, -1130984739, -124916495, -1544436836, -1863524031,
1024916487, -1388636482, -1573205065, 892628956, 1831270021, 1176430590, 1158914682, -2006787098, -1228130033, 1516111488, -1499151347, 470546266, 1642603981, 1425140838, -1823071475, -1775267236,
-1009380612, 164746986, 1129677098, 1842642579, -482342932, -507480364, 1656012309, 1981601761, -881042120, -511987083, 342447017, 381192578, 983008095, 741012865, -1877136350, -199211983,
-452784912, 1929572576, -1678291139, -864375281, -1610561247, -1936356726, -749553767, -865893512, -567081879, -1303973729, -939636958, -622974563, 428284937, 1049237414, 852280765, 86648946,
-1353851401, -1045422335, 898035731, -1636093996, -1083174191, 245046915, -359768226, -1028491655, 1051575118, 1774289451, 1839389415, -1594053468, 736707953, 1873556950, 401186168, -583669552,
-88375334, 2002752071, 264506453, -1304812107, -759203942, -114958524, -1878903503, 841613720, 1910863820, -1738114003, 701455920, 1791058048, -1850960547, 1672292671, 1172188809, 604848896,
-1607489375, 305370478, -948153885, -1971080100, -1848966954, -584538365, 39416319, -1689119162, 944942598, 1777111075, 1534005553, 2022718432, -25820385, 3077695, -315950520, 1859184648,
-1397829266, -1666371809, 858913807, -610818620, 1554973298, 580023809, -1662988256, -408630026, 1316681876, 738204271, 942829881, -758486983, 780345857, 667165037, -2086803585, 789741324
};
for (int i = 0; i < refInt.length; ++i) {
Assert.assertEquals(refInt[i], mt.nextInt());
}
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/random/Well44497bTest.java 100644 1750 1750 40537 11532241241 27070 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.random;
import org.junit.Assert;
import org.junit.Test;
public class Well44497bTest {
@Test
public void testReferenceCode() {
int[] base = {
740849862, 1202665156, -199039369, -259008301, -291878969, -1164428990, -1565918811, 491009864,
-1883086670, 1383450241, 1244617256, 689006653, -1576746370, -1307940314, 1421489086, 1742094000,
-595495729, 1047766204, 1875773301, -1637793284, 1379017098, 262792705, 191880010, -251000180,
-1753047622, -972355720, 90626881, 1644693418, 1503365577, 439653419, 1806361562, 1268823869
};
int[] init = new int[1391];
for (int i = 0; i < init.length; ++i) {
init[i] = base[i % base.length] + i;
}
Well44497b mt = new Well44497b(init);
int[] refInt = {
-102003638, -1254584449, 836441550, 1949705484, 653000494, 1579400718, 699652570, -140738233, 1164288466, 419933874, 366568847, 780567309, 1867405910, -350557801, -964350642, -1323492759,
191502468, 398676344, 1568976991, 1005053759, 199053603, 31083944, 74697788, -1343941248, -1205631880, -1637961625, 361813531, -1706096179, -403340909, 1666226814, -2034962600, 1237102662,
-1833248535, 1584255126, 1295661745, -1753848945, 1208145993, 930278953, -733716134, 192752767, 1692463060, 1727273316, 2122952931, -809025255, -992081044, -895539688, -419372543, -1835478922,
2089629419, 1646590742, -1261083717, -1005462992, 1619627287, -1437723182, 1619689210, 1319393089, -1816963183, -150214444, -513482220, 1897815796, -1861960936, -1766444468, 2034653890, 585657634,
1867016559, 696942260, -1536237241, -527055447, -1554805020, -1063992566, 1024799415, 1782080572, -1884276362, 129028272, 1427925968, -1154222271, -1383146732, -1580532830, -1907049616, -104299169,
-1780913000, -2090815339, -1789809502, -1521443849, 1226625769, 1126090676, -2117094290, -449575109, -218982833, -695554478, 35923022, 1386126825, -95031305, -168657023, 436674049, -1137917876,
-2045134053, -1025629865, 133144659, 64226081, -1966942130, 700813483, 344058910, -910646033, -212789479, 740360859, -1269028713, 1517763679, -664178514, -683718472, -71951996, 86583727,
-1235669348, -1426987265, -166598353, 214190040, -1436967644, 233824411, 710927452, -1939548641, -433607408, -1075939594, -1549702826, -1310827917, -640604762, -696863672, -1282162126, -546470833,
-1516734192, -513809904, -458526835, 708926727, -476643096, -2108375037, -2870478, -1460116421, 436587555, -948939610, 1891375124, 1944216545, 959034236, -1267038790, -1695098736, 1853748495,
1594424552, 1270099319, 1139585482, 1837434635, -709909535, -457524230, -887118113, -241703912, -1888225819, -751575804, 1122280146, 1194255209, 949350188, 892826516, -791212042, -151203035,
-859297731, -1979039938, 323603119, -1022065097, -1804294506, -385802891, -2127523442, -720380255, -1315859127, 999649487, 335041941, -1732821688, -1833409827, 535715225, -1285355653, 1206723386,
-1141619270, 759796285, -1599504546, -1988521411, 1056668895, -852564594, 1056509609, -1831687977, 754168875, -1301144422, 922880446, -1502666503, -949791898, -1043870198, -1136941938, -1649670259,
1342769348, 1692605059, -132279148, -1108038310, -14355545, -1611387086, 1651826569, 877600127, 1356160799, -759125205, -1300490081, -414938486, -201479285, 1958709363, 1513313540, -1396836908,
1352702612, 1142506253, 52969438, -365142357, -1619054179, -1368514102, 1470750417, -1420830959, -843909462, -1679570143, 1447444607, 234551752, -1507452115, -1433234579, -680890000, -497305145,
860408898, 263376761, 1537070218, -592353956, 1587852989, 1756653749, -2081320633, -1547020311, 723771611, -883819383, 1899879513, -268417584, 1058606451, 1665941493, -1630340612, -614737477,
891313237, 1368950660, -1166187089, 296322368, -1908770726, -2120378408, 1245479677, 1879710487, -1705947124, 1018371589, -1715010575, -1096078094, -1749891454, 2130888667, 318647750, 554592231,
-489121568, -1809605233, -1697905160, -953926536, -2013960553, -148884919, 1822739964, -1466301760, 141999978, 1946526064, 1323036718, 864390149, -2141665227, 1510602225, 1468408474, 1277039721,
-1368096647, 180965986, 2140852057, -688071899, 819713016, -154385940, -1182972611, 1257224305, 1392607672, 1364245931, -1768434401, 323522132, -555278604, 474186520, -1178901665, -2137343658,
1636421121, 1398987084, 1276656225, 1013316006, -955917865, -1537149363, -179145358, 342862050, 1172728007, 736300054, -1114656959, -1831840325, -1882353535, -442915191, -1206488416, -1818534411,
25312311, 2100297098, -1562767719, 1762553519, -1853194231, -1152612739, -2020055792, -809572150, 848584579, -535789699, 1817604709, 1343773216, -602234204, 1739930964, -833790834, 501215449,
-730104057, 1217783189, -681773267, -611951354, 978387629, -1516811237, 974303980, -1389665696, 2091099075, -727528826, 2116026151, 271935854, 613242379, -2100429856, 190004963, -1629612570,
-1362888327, 175094223, -917873219, -2008308245, -401946815, 504218792, -1966525201, 4106248, 164895454, 226502921, 655865257, -610528718, 189428750, 1055978898, 17603028, 591024369,
1127922501, -1546639293, 1994174637, -724136988, -673919372, -1665002120, -612145705, -793102882, -1904763558, 757565058, -2091240021, -2123324826, -1518702766, -802889839, -223045921, -1509216579,
1195556261, 2079259971, -903969953, -1781800655, 1834950463, -956531922, -1152550807, -1116052662, -348802884, -1395330117, -91758501, -19115285, 1926930669, -1015793599, 545904386, 1617858191,
716963473, 1917089719, -980914811, -212646927, -1634695647, -1857924568, -1462257477, 1273750178, 1060328454, -361604424, 867932749, 451213698, 405780152, 1165233215, 1877230909, 2103114395,
1644330815, 1252998537, 1961603970, -1533101488, 1790456024, -38226118, -1306744489, 713676418, -1535871838, 1378109935, -338185548, 1647669762, -477465913, 203482277, -1949756706, -503326093,
-638704909, 320186309, -1435581459, 907446649, -77384645, 537368928, -335347295, -1912061924, 547819174, -225549827, 1089455486, 463516297, -240127764, -85895271, 2053179697, -287394931,
921878827, -933362608, -1178670275, -1200942874, -672571265, 574422382, 1441734039, -1814493454, 165751640, -176907245, -1170992192, -2123252090, -1435971541, 1591853830, -885477992, -792847559,
1359875286, 1038392904, -2027255124, 687291425, -165513490, 1391146576, -1387080955, 794663652, -807189965, 667820962, -545384499, -1371368854, -689031878, 1504805541, -752825823, -1920047745,
-1884874017, -350566320, -197152911, -181743050, -798415949, -915922276, 1790690149, -363997181, 1923116185, -1326427198, -1621079427, -1997440997, 1798118127, -2053110382, -159879848, -1286787216,
1046436411, 1832030471, -389092059, 71686169, -76025260, 1914270607, 1854169353, 872157826, -1774323792, -575165717, -1919931724, 2051498109, -1176174934, -883578901, -1253047270, -1310573900,
245466682, -1784824328, -1319912821, 1377340217, 1364313761, -408687373, 142333378, -1952335763, -1703126184, 316314678, 2030555423, 488640834, -1783293306, 2116925005, -428337460, -42966447,
-476226114, -325172903, -1690748475, 852791569, 26490302, 85251337, -1374975770, -376283969, 982639600, 595119792, 376403422, 1574509912, -1509664496, -1901241749, -59019104, 358566667,
341667214, 184541206, -550950854, -1897143732, 1595753537, -1236127928, 2014297822, -2033179270, -669806121, -1927596980, 1010735700, -581795164, 1922398838, -1456743538, -1633813803, 323177707,
2002098813, -2099067658, 277393729, -671911622, -384463053, 2028267908, 367391785, 1270052637, -172839030, -650486693, -831800809, -1255138113, -137512799, 1904317942, -8229811, 707361898,
-276859812, 50417442, 1487081728, 1577776181, 1994451303, 1237303035, -602016235, -1905218276, -1895725672, 1172978849, 801129953, -1819485071, -587985848, -2010386741, -1645226427, -850866837,
816998708, 357665811, 1955856762, 1617902189, -1013761306, 146782652, 904185608, -500146809, 2085848310, 1917713975, -1823786899, 1994184748, 789196322, 1766857258, 1770685286, 58213029,
-1699628994, 346827379, -1274423227, -5079670, -193099487, 1020296939, -1795904054, -1951053094, -43782418, -375403393, 1026761026, -207269610, 1364563521, 1578793454, 457809423, -534138380,
-1052938788, -1897101526, 1449976516, 2052800058, -1145169719, 1476303269, 370625650, -325249282, 2165984, 1631432802, 1032336355, -1292978191, -1810172401, 725725820, -1162678778, 702624490,
1387673527, 981825943, -556408212, -1108487850, -1782136935, 1582316425, -1752682164, 307235003, 1386486299, -1343636074, 1936875586, -1265279891, -345847069, 928241171, 239050350, 1859358526,
-664776217, -823267892, 346651710, -867656288, -1907921425, 1362445801, 541145461, -192727350, 1649366606, 244694627, -488180018, 214008256, 2032125437, -1678591993, -264593820, 1309017286,
-652451998, 1845366657, -703990120, -550186406, -630285276, 1782372955, 1650564210, -1127904234, -1407983860, -1119422877, -1565976361, -1913545385, 549841420, -1410323732, -1964467146, 228296551,
-421026422, 1929094398, -266906424, 264810315, -2008122665, -1088278148, 141242192, 1871293282, 234634067, 1724159838, 1638271051, -837713428, -657941661, 168093988, 708605363, -1881612509,
-1810496006, -193495322, 1889982309, -2050702012, -693694192, -1249780322, 718733403, -76349730, -188217051, 920912090, -1814078273, 2013358456, -1948845521, -198407575, -1248904632, 1182772565,
1236791612, -1297489171, -1958468586, 1437011007, 390460941, 113068796, 1247982993, 2102889679, -1563524844, -128174212, -754095070, -1461699362, 943615640, -1013270737, 221253920, 1514140013,
1596946745, 674222984, 616356702, 1811224435, -1764322023, -1653707581, -1702404459, 390678142, -209506765, -1398278531, -117061517, 1625861343, 659048069, -1490678943, 846536668, 210715637,
1855458786, 1727745280, 1086729456, 1109111683, -985298098, -1813777567, -954599702, -1522494031, 1166103515, -191868965, -1048777852, -661271058, 1161457421, 1509090409, -919753558, -155431193,
-1774302994, -366390263, 2090138916, -693431491, -1693888428, 1846774454, 925855693, 474383470, 208889079, 382195164, -283005634, -2095134392, 579927985, 1390765326, -1766119865, 900457129,
-1503703236, 974952690, -107714111, 381338452, 1187256613, -860560742, 524103620, 1499506130, 197755276, -790802926, -406920967, -1972219791, -665721155, -113336203, 1037154436, -1185441801,
-745541706, -546274471, 1988928457, -1975403782, -1167172845, 777779004, -1560935061, -140258712, -1243598232, -1394149587, -785002782, 311842991, -1025469277, -605350463, -1251538057, 537203966,
597777961, -1845767072, -1556349193, -1491015509, -1935936671, 2093498487, 1908270236, -315396187, 1356362300, -2025658518, 630119678, 276190559, 510123398, -1266145363, -170152124, -151540077,
-477900187, 1895894303, 1870333068, -1169891437, 353366620, 2111175941, 1691245786, 1318765802, -90993610, 921309517, 118241505, 367005284, 1624861072, 2010785894, 865255951, 1717799691,
-80757664, -644944841, 136999836, -341686875, -1908076090, -1968934200, -346397811, -184213520, -511811333, -2118173466, -1086490399, 1795322855, -635494328, 415716276, 851044432, -904636831,
-1972230341, -64337858, 571177016, 1248814747, -1351030778, 457872680, 1843549954, 1718960038, 815088665, 1812961065, 360686952, -1356586646, 1657802416, 1776192945, -786723490, -342254407,
-236653811, 771014701, 906386785, -308057635, 1907957462, 206000440, -42143480, 900403654, -917549795, -310520796, -1713627766, 2061136240, -377977839, 891282946, -821163030, 328143584,
1503793080, 551621842, -2086273683, -2070526343, 91195293, -1654389038, -1035734266, -336619597, -1220221027, -1468468844, 2105626873, -841372573, -122707018, -2013073683, 494461000, -2054807734,
-67946259, 1914163407, 1941835405, -1027244745, -768123277, 419129844, -275750260, -171533009, 97756174, -17651409, -1578102255, 995291430, -1587462977, 692904675, 951632643, 1882101293,
-1546298756, 2018418068, -1790777661, 1542305514, -1437624383, 469587009, -1647853474, -1318279028, 497228822, 726733469, 1693133452, -2091185798, -209017732, 126386499, 1056958932, -2105494133,
754067324, 96463951, 83701151, 1101658289, 1485852701, 553783806, 1898769881, -1072031442, 1438062141, 1992540265, 1152252136, 1019391719, -175951257, -6691216, 989789689, 968359367,
-1330392786, 1704963399, -998432914, -948060232, -1921688855, -975840920, 1360273515, -872810459, 12676907, -1908050756, 883609616, 65641549, -200365398, 1386653304, -1203665071, 1878689007,
426262328, 315375145, 1900325181, 703658494, -765404895, 1070155172, 1399748900, -804264234, -1619419026, 1347225486, 230635292, 1093717835, 14020583, -2107039873, -968325341, -1679158691,
1959784097, 1065690797, 1090615161, 1311445364, 865835426, 870016646, 574122879, 1842697922, -1289210431, -1914001560, 1672467629, -900366331, -1524066872, 136503816, -1910431892, -1431958329,
-830367152, -1316233970, -801974860, 1560669382, -81784810, 401822577, -949103202, 943897151, -722666726, -96825841, -1092898846, 230567004, -70355840, -1398069192, -312953142, 1475420133,
-622491023, 1661205388, -19071322, 6024591, 1473041593, 2053897978, -1346768903, 1484764721, -1552461890, 1287146711, 1613069307, 902497864, -1504480063, 375292915, -836353108, 2047602411
};
for (int i = 0; i < refInt.length; ++i) {
Assert.assertEquals(refInt[i], mt.nextInt());
}
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/random/GaussianRandomGeneratorTest.java 100644 1750 1750 3013 11532241241 32135 0 ustar luc luc 0 0 //Licensed to the Apache Software Foundation (ASF) under one
//or more contributor license agreements. See the NOTICE file
//distributed with this work for additional information
//regarding copyright ownership. The ASF licenses this file
//to you under the Apache License, Version 2.0 (the
//"License"); you may not use this file except in compliance
//with the License. You may obtain a copy of the License at
//http://www.apache.org/licenses/LICENSE-2.0
//Unless required by applicable law or agreed to in writing,
//software distributed under the License is distributed on an
//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
//KIND, either express or implied. See the License for the
//specific language governing permissions and limitations
//under the License.
package org.apache.commons.math.random;
import org.apache.commons.math.stat.StatUtils;
import junit.framework.*;
public class GaussianRandomGeneratorTest
extends TestCase {
public GaussianRandomGeneratorTest(String name) {
super(name);
}
public void testMeanAndStandardDeviation() {
RandomGenerator rg = new JDKRandomGenerator();
rg.setSeed(17399225432l);
GaussianRandomGenerator generator = new GaussianRandomGenerator(rg);
double[] sample = new double[10000];
for (int i = 0; i < sample.length; ++i) {
sample[i] = generator.nextNormalizedDouble();
}
assertEquals(0.0, StatUtils.mean(sample), 0.012);
assertEquals(1.0, StatUtils.variance(sample), 0.01);
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/random/Well1024aTest.java 100644 1750 1750 22315 11532241241 26754 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.random;
import org.junit.Assert;
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
import org.apache.commons.math.util.FastMath;
import org.junit.Test;
public class Well1024aTest {
@Test
public void testGaussian() {
Well1024a mt = new Well1024a(42853252100l);
SummaryStatistics sample = new SummaryStatistics();
for (int i = 0; i < 10000; ++i) {
sample.addValue(mt.nextGaussian());
}
Assert.assertEquals(0.0, sample.getMean(), 0.004);
Assert.assertEquals(1.0, sample.getStandardDeviation(), 0.003);
}
@Test
public void testDouble() {
Well1024a mt = new Well1024a(195357343514l);
SummaryStatistics sample = new SummaryStatistics();
for (int i = 0; i < 10000; ++i) {
sample.addValue(mt.nextDouble());
}
Assert.assertEquals(0.5, sample.getMean(), 0.0006);
Assert.assertEquals(1.0 / (2.0 * FastMath.sqrt(3.0)),
sample.getStandardDeviation(),
0.002);
}
@Test
public void testFloat() {
Well1024a mt = new Well1024a(4442733263l);
SummaryStatistics sample = new SummaryStatistics();
for (int i = 0; i < 10000; ++i) {
sample.addValue(mt.nextFloat());
}
Assert.assertEquals(0.5, sample.getMean(), 0.0001);
Assert.assertEquals(1.0 / (2.0 * FastMath.sqrt(3.0)),
sample.getStandardDeviation(),
0.003);
}
@Test(expected=java.lang.IllegalArgumentException.class)
public void testNextIntNeg() {
new Well1024a(1).nextInt(-1);
}
@Test
public void testNextIntN() {
Well1024a mt = new Well1024a(0x12b8a7412bb25el);
for (int n = 1; n < 20; ++n) {
int[] count = new int[n];
for (int k = 0; k < 10000; ++k) {
int l = mt.nextInt(n);
++count[l];
Assert.assertTrue(l >= 0);
Assert.assertTrue(l < n);
}
for (int i = 0; i < n; ++i) {
Assert.assertTrue(n * count[i] > 8600);
Assert.assertTrue(n * count[i] < 11200);
}
}
}
@Test
public void testNextInt() {
Well1024a mt = new Well1024a(new int[] { 1, 2, 3, 4, 5 });
int walk = 0;
for (int k = 0; k < 10000; ++k) {
if (mt.nextInt() >= 0) {
++walk;
} else {
--walk;
}
}
Assert.assertTrue(FastMath.abs(walk) < 70);
}
@Test
public void testNextLong() {
Well1024a mt = new Well1024a(12345);
int walk = 0;
for (int k = 0; k < 10000; ++k) {
if (mt.nextLong() >= 0) {
++walk;
} else {
--walk;
}
}
Assert.assertTrue(FastMath.abs(walk) < 70);
}
@Test
public void testNexBoolean() {
Well1024a mt = new Well1024a(76342);
int walk = 0;
for (int k = 0; k < 10000; ++k) {
if (mt.nextBoolean()) {
++walk;
} else {
--walk;
}
}
Assert.assertTrue(FastMath.abs(walk) < 180);
}
@Test
public void testNexBytes() {
Well1024a mt = new Well1024a(0);
int[] count = new int[256];
byte[] bytes = new byte[10];
for (int k = 0; k < 1000000; ++k) {
mt.nextBytes(bytes);
for (byte b : bytes) {
++count[b + 128];
}
}
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
for (int c : count) {
min = FastMath.min(min, c);
max = FastMath.max(max, c);
}
int expected = (1000000 * bytes.length) / count.length;
Assert.assertTrue((expected - 600) < min);
Assert.assertTrue(max < (expected + 600));
}
@Test
public void testReferenceCode() {
Well1024a mt = new Well1024a(new int[] {
740849862, 1202665156, -199039369, -259008301, -291878969, -1164428990, -1565918811, 491009864,
-1883086670, 1383450241, 1244617256, 689006653, -1576746370, -1307940314, 1421489086, 1742094000,
-595495729, 1047766204, 1875773301, -1637793284, 1379017098, 262792705, 191880010, -251000180,
-1753047622, -972355720, 90626881, 1644693418, 1503365577, 439653419, 1806361562, 1268823869
});
int[] refInt = {
-1478749726, -1645579484, -2075363835, -2063444174, -1834148336, -1769045872, -40711346, 1717441026,
2130656771, 783441285, 570433609, 1560023451, 653233971, 1368672434, -72036215, 1071111800,
933776492, 26114960, 49888778, 1808107515, 1092989296, 754848337, 1336994364, -1987450448,
-691190146, -1803870839, 1110716866, 1173269113, -391000050, 2014216908, 180756301, -382891013,
-1908154585, 1580737629, 1080267957, -125532248, 2094530239, 2132964485, -438596348, -760299445,
1058181869, 2050816800, -1534429037, -62552782, 824524142, -818590371, -1857695907, -684762866,
-156556543, -902759995, -880795194, -1387351132, -1263017515, 448006597, 201038266, 1929826313,
-455367306, 672963027, 2000073013, -1546842042, 446341090, 1001696686, -779919012, -347722602,
-1342821677, 1639571150, -835315755, 1505585376, 367004975, -2035864404, -1786623553, 1249724913,
182435312, 1444514513, 1815333708, 1333772382, 299664001, -284691169, 2034403374, 1423310887,
-1319051884, 1557286441, -445198266, -251809030, 1602786123, 944036382, -1020529634, 258344235,
685254367, 1838964943, -156674528, -979736602, -538312836, 234643178, 211152102, -635498640,
-1036733933, -1347589147, -565609042, -1358714165, 508618483, -786364693, 2071450261, 1206956772,
-678931458, 167690617, 144698821, 1719720781, 1575869280, -1343221123, -1766469944, 284991647,
-717305514, 892653651, -1368347075, -615701972, -730369849, 1360396003, -1869287623, 1778269052,
-586061545, -699517114, 61530249, -1860611767, -519660852, 1841085925, 1555610093, -399979337,
-790345742, 422355947, 2007965433, 2044952550, -1712164595, -102915702, -693865324, -1894042487,
-1285020072, -215883074, 95833252, 1625818040, -1055951680, 513067085, 1825246558, -553461652,
-1923361799, -1869480206, 567232636, -1751727150, -1832301399, -108136455, -1312244126, 14006795,
850221366, -382389732, -1741556188, -1317464467, 1948314870, 753994471, 1028235947, 342494132,
-1862256693, 723808794, -234257642, 1609928369, -802733456, 1315831915, 1436072885, 1224767136,
2144557791, -1839965886, 224821018, -1461697757, -1080386760, 1638573498, -1188173812, -325181523,
-1750676219, -1780415850, 698793362, -908352052, 299746482, -161660934, 1938166833, 800297005,
56640033, -1214932666, -1248124842, 1822796868, 1777615881, -718517774, 1908159957, 1733053281,
1851844331, 1283519375, -1771494956, 2060179999, 1666129209, 1919453531, -498145770, 697567008,
1855487148, -1587163491, 565216434, -1477877933, -925662919, -806492585, -1201439047, -1424534232,
1788616523, 69414717, 655893636, -1175978556, 24787512, -861550001, 439525754, -190433174,
-383811606, -508589783, 1441608687, 608181366, 1539467064, 925903122, 697209654, 1878283393,
-1967567432, -1659677763, -249658183, 847096354, 397741956, -125334541, -1286840731, 1016461908,
-997968592, 1795331475, 1856856501, -1716726445, -582181331, -887091847, 426964855, -609219941,
-1456232632, -483467616, 1069260754, 972242064, -1406786247, 1954194029, 52627891, 1212755081,
2117436668, 281073392, 741537353, -483063506, 1850906286, -244876135, -270818140, 1817568823
};
for (int i = 0; i < refInt.length; ++i) {
Assert.assertEquals(refInt[i], mt.nextInt());
}
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/random/UniformRandomGeneratorTest.java 100644 1750 1750 3006 11532241241 32004 0 ustar luc luc 0 0 //Licensed to the Apache Software Foundation (ASF) under one
//or more contributor license agreements. See the NOTICE file
//distributed with this work for additional information
//regarding copyright ownership. The ASF licenses this file
//to you under the Apache License, Version 2.0 (the
//"License"); you may not use this file except in compliance
//with the License. You may obtain a copy of the License at
//http://www.apache.org/licenses/LICENSE-2.0
//Unless required by applicable law or agreed to in writing,
//software distributed under the License is distributed on an
//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
//KIND, either express or implied. See the License for the
//specific language governing permissions and limitations
//under the License.
package org.apache.commons.math.random;
import org.apache.commons.math.stat.StatUtils;
import junit.framework.*;
public class UniformRandomGeneratorTest
extends TestCase {
public UniformRandomGeneratorTest(String name) {
super(name);
}
public void testMeanAndStandardDeviation() {
RandomGenerator rg = new JDKRandomGenerator();
rg.setSeed(17399225432l);
UniformRandomGenerator generator = new UniformRandomGenerator(rg);
double[] sample = new double[10000];
for (int i = 0; i < sample.length; ++i) {
sample[i] = generator.nextNormalizedDouble();
}
assertEquals(0.0, StatUtils.mean(sample), 0.07);
assertEquals(1.0, StatUtils.variance(sample), 0.02);
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/random/Well19937cTest.java 100644 1750 1750 40636 11532241241 27072 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.random;
import org.junit.Assert;
import org.junit.Test;
public class Well19937cTest {
@Test
public void testReferenceCode() {
int[] base = {
740849862, 1202665156, -199039369, -259008301, -291878969, -1164428990, -1565918811, 491009864,
-1883086670, 1383450241, 1244617256, 689006653, -1576746370, -1307940314, 1421489086, 1742094000,
-595495729, 1047766204, 1875773301, -1637793284, 1379017098, 262792705, 191880010, -251000180,
-1753047622, -972355720, 90626881, 1644693418, 1503365577, 439653419, 1806361562, 1268823869
};
int[] init = new int[624];
for (int i = 0; i < init.length; ++i) {
init[i] = base[i % base.length] + i;
}
Well19937c mt = new Well19937c(init);
int[] refInt = {
2128528153, 327121884, 935445371, -83026433, -1041143083, 2084595880, -1073535198, -1678863790, -523636021, -1514837782, -736786810, 1527711112, -1051227939, 978703380, 410322163, 1727815703,
-648426354, 636056441, 1954420292, 17754810, -958628705, -1091307602, 1793078738, -1680336346, 1792171272, 941973796, -2066152330, -1248758068, -1061211586, 262020189, 1276960217, -233886784,
1767509252, -1811939255, -406116097, -742435920, -1349799525, 240329556, -332161345, 1488943143, -332244280, 2093328957, 674753300, -1930135556, 257111467, 63793650, -1964335223, 1315849133,
-797349146, 1372022250, -1451892049, -1325138957, -870401239, -1294317369, 91490879, 386205044, -704074702, -1230679067, 1513674392, -262996240, 1196007314, 1398903796, 803719762, -1750926831,
-1268814180, 1233515404, 1498313934, -970591257, 611113671, -261632474, 1834097325, 1709440492, -150396854, 2120561003, -62645660, 479080234, 1535125050, 1823378695, -1129289329, -1095198399,
2092564733, 78836308, -692015409, 1647147229, -1847922219, 1838279320, -848333841, -1375151778, 920238861, 1512628290, -749439404, 288851918, -427218675, 679640964, 425700808, -2077624511,
-1929434455, -647176419, 650437190, -1926749131, -1564744729, 734494454, 108193743, 246246679, 810042628, 1952337771, 1089253730, -1874275331, 1428419392, -492969232, 1945270770, -201265602,
-755490251, -624426214, -699605715, -113446478, 809091299, -1521531511, 1136505389, -523660964, 132928433, 1926559713, -1485314325, -508322506, 46307756, -1627479740, -589386406, -1855555892,
584299545, 1272841066, -597242658, 925134545, 1102566453, -753335037, -9523218, -1778632375, 568963646, 764338254, 1259944540, -2000124642, 1307414525, -151384482, 807294400, 1993749511,
-15503094, -709471492, 2104830082, 1387684315, -1929056119, 224254668, -733550950, -889466978, -1987783335, -437144026, 995905753, -1021386158, -1096313388, -1014152835, -1303258241, 1201884788,
-1845042397, 1421462511, 980805867, 2143771251, 481226968, 1790544569, 328448328, 1995857639, -66668269, -1411421267, -222586606, 866950765, -308713926, -1048350893, 993222402, -1139265642,
-871837948, 1145571913, 381928580, 35386691, 1640961123, -1192981020, 775971009, 594246635, 1603197812, -575106766, 2023682000, -1636301903, -718093720, -1666421635, -2146115988, 320593570,
287355418, 454400027, 1112753817, 1751196267, 782077910, -1478447368, -1007557264, -862315517, -2035355952, 2123515250, -557641502, -1789932035, 879640129, 44167603, 791148984, 1382939723,
-2135684233, 1825489580, 937345485, -1839983359, -1536880111, -1472578359, 1548052748, -1471535862, -14508727, 1509621398, -2134967452, -787485401, 815341660, -327905128, 1028096737, 866906991,
-1585990806, 859229080, 234806270, 998518056, -1897890815, -900923587, 1179856752, 1529572451, 620486106, 1119836556, 1661285564, 2097404633, -1437490790, 265306115, -984880135, 1326751968,
1280043536, 680210701, 155786166, 1550973250, -325781949, -597789777, -1939780, 1345275487, 1930450001, 941449704, 669301309, 693651713, -990721514, 582968326, 976132553, -1892942099,
-1065070157, -711990993, -688974833, -1026091683, 1115346827, -1305730749, -1733626381, -364566696, -21761572, -37152746, -262011730, 1302722752, -1806313409, -767072509, 764112137, 1671157377,
1837645038, -1021606421, -1781898911, -232127459, -310742675, -1818095744, -1128320656, -705565953, -354445532, -523172807, -433877202, 131904485, -64292316, 381829280, 229820263, 1797992622,
1359665678, 978481451, -885267130, -1415988446, -356533788, -961419072, 1938703090, 708344111, 679299953, 744615129, 1328811158, 1257588574, 569216282, -753296151, -1519838713, 2016884452,
1062684606, 1561736790, 2028643511, -1353001615, 886376832, 1466953172, 1664783899, 1290079981, -57483993, -1176112430, 1634916316, 1976304475, 1374136869, -648738039, 1058175869, -909000745,
-1526439218, 726626991, 2066596202, 64980943, -26166577, -885900005, -1821546816, -1103727665, 730606315, -1324948459, -696956940, -1300869403, 1171578314, 797249074, -1600611618, 1928247682,
307164165, -1482476232, -1886179640, 1306433392, 1945271359, -1272113751, -1285984081, -2057145549, 795047465, 1262569087, -1239828121, 1426641636, -786371495, 2120199316, 1273690652, 74457589,
-1033394229, 338952565, 46122958, 1225741533, 2115308090, 678200841, -1618264885, -101162569, -1628976330, -1232839500, 468709044, 1876019116, 92723122, 233398255, -554960844, 38494196,
-406437278, 2083528643, -1106878615, -340722557, -2123964932, 223183343, 108918116, -1014629054, -901344544, -838896840, -1908460517, -1763508731, -926890833, 1703791049, -667755577, 1694418389,
791641263, 1095689677, 1119202039, -1419111438, -2012259010, 188017439, -1775110395, -1971099661, -1688113734, 131472813, -776304959, 1511388884, 2080864872, -1733824651, 1992147495, 1119828320,
1065336924, -1357606762, 462963503, 1180719494, -202678962, -892646595, 605869323, 1144255663, 878462678, -1051371303, 872374876, 631322271, -172600544, -1552071375, -1939570033, 151973117,
1640861022, 310682640, 34192866, 2057773671, -2004476027, -1879238973, 582736114, 900581664, -427390545, -1232348528, -535115984, 1321853054, 69386780, -1729375922, 1418473715, 1022091451,
496799289, -80757405, -1903543310, -1128846846, 1703964, 1984450945, 856753858, -812919184, 775486323, -1376056193, 638628840, 314243536, 1030626207, 644050997, 73923896, 362270613,
236584904, 1463240891, -223614432, 435371594, -751940030, -124274553, -1991092884, 1579624267, 1249632649, 157589625, -345229739, -366245207, -1399995986, 1651729983, 1965074340, -1108970305,
1163690769, 1732013523, -1461252895, 669755552, -476503675, -264578685, -32813949, 288222188, -25734262, 106040916, 1654395626, -365148479, 2014455846, -2040447994, 1351639280, -919975757,
-1970412139, -47306532, 222377665, -363434917, -1091717516, 2090685531, -1221091649, -1729649190, -1239406708, 1064945398, -105437479, -419675255, 74701669, -12862899, -498269844, 1566898997,
-1872838355, 1596887574, 485902962, 469225597, -881763553, 1307841032, -1642872487, 1388543045, 379792876, 1095683384, 840780732, 1934378038, 1851278350, -1359389423, 130868458, -313448799,
-663624816, 1031714153, -608443411, -205137499, -1849464427, 1973593637, 1068741808, -1420655961, 1188762305, 954044841, -995454462, -1818101092, -1937201943, -324541290, -1520603933, 572873173,
-554764496, 1051557081, -1245136076, -985349536, 329320398, 1787901464, -37803304, -1759310177, -1463492617, -1861729663, 1251768782, 256937091, -779036948, -2049893864, 1256022877, 1228075657,
-1550195255, -611319853, 1190797155, 2047604112, -576077160, -1532843331, -1324899394, -159729560, -622525946, -1080302767, -236033484, 1895243903, -410123689, -1944154157, -681781021, 1208453003,
579595878, 1303914051, -145607082, -131567277, -1917288455, 894217359, -175688726, -1585480723, 663691440, -1140068263, -641711178, 1596080008, 629197693, 976422358, -1570451095, 525923776,
895046136, -504151767, 1602553020, -1233054923, -1798474837, -1488857895, 1055782627, 261863143, 1879276655, 488240679, 1910982611, -1919441259, 370435945, 1265230086, -1293284428, -1503576227,
2076963035, -1379628250, 1157098875, 1984461153, -1947837397, 1705880124, 1453607404, -1233649748, 1479943773, -863878721, -862415630, -736723275, 940306358, -1596000684, -1174889953, -615723892,
-885006597, -1796723178, 1844159055, -188942309, 2107251811, -1675486996, -1009475178, -859263556, -431866963, -9593673, -1878920923, -104853791, -1535224994, -69315537, 586690130, -1292234796,
1378749456, -301873019, -319297563, 1677205851, 292450579, -1289441171, 1788113680, 1907606333, 1464711611, -1372023606, -1978832445, -1772259768, 1949124464, 1818322887, -1138036603, 1249727628,
-1474866449, -1868013169, -1384567593, 717007936, 954189997, -1900561040, 738470389, -158973180, 1732860784, 1936031206, -1133354740, -1173166665, 1432976712, 852636081, 1732064691, -1831788120,
1273933579, 455403217, 1988395890, 106493468, 506092152, -610530423, 1698053512, 1311747476, 1969503012, -1887461759, 1613543073, 903200334, -737865837, 325656800, -1234001200, 1492148864,
2009861533, -368262605, 1091338541, 2076108119, -961392337, 1835877112, 316250307, -853333391, -2125443777, 815363504, -798707803, -158146540, 690786114, -530775684, 1203556940, 1611485582,
-1661412270, -53184506, 2126287444, -232222229, 1559486057, 283532250, 1202760418, 932144172, 1082594656, -570104011, 413509167, -995027177, -996477516, -540544, -745537167, -712135469,
-996294983, -592787198, 1889840948, 1314628747, -394266926, -682316577, 456447239, 1728806063, -396279614, -43387643, 1915717013, -861574144, -1078710588, -561401249, 1111464540, 63643984,
-1693870413, -968369980, -1053148188, 708799038, 1883537988, 373371671, -156410415, -1596483236, -1846890431, 888692915, -1025632583, -1666477591, -343066267, -2059058792, 641501628, -1744347292,
1648632991, 1743540146, 2020952406, 164014499, 990508262, 1706408228, -1236471842, -347116260, 1843634523, 827255665, 300519853, -1265974830, -547247177, -583064554, -1995437077, 689210107,
-93151393, 835365056, 1706367315, -1605902756, 200954895, 431093688, -277573364, -928486713, -552221973, 145432789, 1128919795, 1675095586, 1930359882, 1215849501, -1447770583, 657776490,
1885869860, -1629237204, -868897479, -1258169760, 1828140195, -883850439, 463933909, -347361158, 1478116648, 801176896, -1501915899, 1017335748, -1654508882, 123994786, 1588785290, 791166651,
-1523108535, 340411166, -496474762, -1189711141, -7392628, 2045171250, -1245366209, 834787230, -1346883181, 2034209454, 737043362, 898803323, 1983089087, -1845404320, 9585188, -1180608323,
1665100606, 1949474222, -211115008, 1151308295, -2132174259, 913126312, -2085061672, 1419864120, -1134542954, -53833957, -246913211, 468382370, -1759479323, 1136686211, 1307012488, -2036299559,
-1346099736, 314743106, -1683101865, -947151948, -234529696, -2103334293, -279256894, -1484257, -1053953017, 1801205399, 941594454, -874119215, -672865187, 762284205, -1494975451, 486607927,
-898264389, -1711861093, -212572760, 2106484281, -1610786470, 1352525590, -837779586, 1568282001, -593019125, -1146260782, -1595879979, -640781858, 1107692311, 1547132709, -1928385535, -2057772805,
634887038, 329772618, 942136006, -864405576, 501883884, 1537141484, -1180626836, 1123055420, 1090885851, 421662750, 2033111605, 1710917425, -1118058244, 74321279, 257328195, -1199940697,
208625996, -442341447, 808119183, 1166827075, 1177417517, -1856155370, -1464837036, -60624923, -1306220638, -91104698, -1434621430, 548899241, 37351476, 1478278431, -1255061434, 248470035,
-104642597, -1865169521, 1418373655, -1660810523, -2129015436, 154612798, 276575732, 1930338442, 179503250, -929294855, -39452027, -1377657544, 1442322193, 1137511318, -432158653, -984801987,
743099148, -1118893528, -904123623, -1273146363, -1884800406, -803169061, 1254123158, -484252077, 317646844, 404246525, -1230293916, 1121445742, -19657507, 652967153, -1055406692, -468950719,
-1493532921, -1447624258, -1369679689, -1517000228, -145853307, 1518006526, 1591195514, -1475557146, -909722097, 2103182976, -406830579, -2124025254, -1804819507, -1357512858, 567321869, 409048156,
567805180, 1749009386, 1762759722, -1770324077, 1271140844, 468219092, 955792405, 1911965665, 1876314424, -718200715, -1278883927, 1392281730, -120519585, 851473793, 245054754, -33369039,
-284877584, -479534880, -212346563, -122017521, -1461429983, 1331007370, 1788621721, 1739036536, 1446350953, -1985448033, 685528610, -1386434659, 1368233993, 2021786790, 1596478397, -1716635278,
-2011083017, 171876097, -311529197, 687812052, 377000657, -1055547517, -1499047842, -1818434951, -120863666, 33888043, -1387509273, -541540700, 1162597745, -1331415338, 1931708792, -850270000,
663845594, 1536495943, -322924971, -1380272203, 261190298, -204874428, -2104974031, 883819928, 155808204, -1454446035, 1323388464, -1696505728, 1549800285, 1018150463, -1327715703, -1582480640,
1013659809, -1820360082, 1666498787, 1406120540, -196541482, 1248470531, -1250433281, 836375878, 177646854, -1927020253, 2145878321, 689712096, -596605921, 348283199, 1916993096, 481356808,
-339687826, 1219340319, 718895887, -2007521340, -1859185806, 2042164737, -58146784, 742449142, 1930754708, 780832111, 715056441, -1393886151, -8150527, -599607443, -537300865, -1212516084
};
for (int i = 0; i < refInt.length; ++i) {
Assert.assertEquals(refInt[i], mt.nextInt());
}
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/random/RandomAdaptorTest.java 100644 1750 1750 5527 11532241241 30122 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.random;
import java.util.Random;
/**
* Test cases for the RandomAdaptor class
*
* @version $Revision: 902201 $ $Date: 2010-01-22 19:18:16 +0100 (ven. 22 janv. 2010) $
*/
public class RandomAdaptorTest extends RandomDataTest {
public RandomAdaptorTest(String name) {
super(name);
}
public void testAdaptor() {
ConstantGenerator generator = new ConstantGenerator();
Random random = RandomAdaptor.createAdaptor(generator);
checkConstant(random);
RandomAdaptor randomAdaptor = new RandomAdaptor(generator);
checkConstant(randomAdaptor);
}
private void checkConstant(Random random) {
byte[] bytes = new byte[] {0};
random.nextBytes(bytes);
assertEquals(0, bytes[0]);
assertEquals(false, random.nextBoolean());
assertEquals(0, random.nextDouble(), 0);
assertEquals(0, random.nextFloat(), 0);
assertEquals(0, random.nextGaussian(), 0);
assertEquals(0, random.nextInt());
assertEquals(0, random.nextInt(1));
assertEquals(0, random.nextLong());
random.setSeed(100);
assertEquals(0, random.nextDouble(), 0);
}
/*
* "Constant" generator to test Adaptor delegation.
* "Powered by Eclipse ;-)"
*
*/
private static class ConstantGenerator implements RandomGenerator {
public boolean nextBoolean() {
return false;
}
public void nextBytes(byte[] bytes) {
}
public double nextDouble() {
return 0;
}
public float nextFloat() {
return 0;
}
public double nextGaussian() {
return 0;
}
public int nextInt() {
return 0;
}
public int nextInt(int n) {
return 0;
}
public long nextLong() {
return 0;
}
public void setSeed(int seed) {
}
public void setSeed(int[] seed) {
}
public void setSeed(long seed) {
}
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/random/TestRandomGenerator.java 100644 1750 1750 2701 11532241241 30445 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.random;
import java.util.Random;
/**
* Dummy AbstractRandomGenerator concrete subclass that just wraps a
* java.util.Random instance. Used by AbstractRandomGeneratorTest to test
* default implementations in AbstractRandomGenerator.
*
* @version $Revision: 811685 $ $Date: 2009-09-05 19:36:48 +0200 (sam. 05 sept. 2009) $
*/
public class TestRandomGenerator extends AbstractRandomGenerator {
private Random random = new Random();
@Override
public void setSeed(long seed) {
clear();
random.setSeed(seed);
}
@Override
public double nextDouble() {
return random.nextDouble();
}
}
././@LongLink 100644 0 0 153 11532242443 10252 L ustar 0 0 commons-math-2.2-src/src/test/java/org/apache/commons/math/random/CorrelatedRandomVectorGeneratorTest.java commons-math-2.2-src/src/test/java/org/apache/commons/math/random/CorrelatedRandomVectorGeneratorTes100644 1750 1750 13017 11532241241 32553 0 ustar luc luc 0 0 //Licensed to the Apache Software Foundation (ASF) under one
//or more contributor license agreements. See the NOTICE file
//distributed with this work for additional information
//regarding copyright ownership. The ASF licenses this file
//to you under the Apache License, Version 2.0 (the
//"License"); you may not use this file except in compliance
//with the License. You may obtain a copy of the License at
//http://www.apache.org/licenses/LICENSE-2.0
//Unless required by applicable law or agreed to in writing,
//software distributed under the License is distributed on an
//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
//KIND, either express or implied. See the License for the
//specific language governing permissions and limitations
//under the License.
package org.apache.commons.math.random;
import junit.framework.TestCase;
import org.apache.commons.math.DimensionMismatchException;
import org.apache.commons.math.linear.MatrixUtils;
import org.apache.commons.math.linear.NotPositiveDefiniteMatrixException;
import org.apache.commons.math.linear.RealMatrix;
import org.apache.commons.math.stat.descriptive.moment.VectorialCovariance;
import org.apache.commons.math.stat.descriptive.moment.VectorialMean;
import org.apache.commons.math.util.FastMath;
public class CorrelatedRandomVectorGeneratorTest
extends TestCase {
public CorrelatedRandomVectorGeneratorTest(String name) {
super(name);
mean = null;
covariance = null;
generator = null;
}
public void testRank() {
assertEquals(3, generator.getRank());
}
public void testMath226()
throws DimensionMismatchException, NotPositiveDefiniteMatrixException {
double[] mean = { 1, 1, 10, 1 };
double[][] cov = {
{ 1, 3, 2, 6 },
{ 3, 13, 16, 2 },
{ 2, 16, 38, -1 },
{ 6, 2, -1, 197 }
};
RealMatrix covRM = MatrixUtils.createRealMatrix(cov);
JDKRandomGenerator jg = new JDKRandomGenerator();
jg.setSeed(5322145245211l);
NormalizedRandomGenerator rg = new GaussianRandomGenerator(jg);
CorrelatedRandomVectorGenerator sg =
new CorrelatedRandomVectorGenerator(mean, covRM, 0.00001, rg);
for (int i = 0; i < 10; i++) {
double[] generated = sg.nextVector();
assertTrue(FastMath.abs(generated[0] - 1) > 0.1);
}
}
public void testRootMatrix() {
RealMatrix b = generator.getRootMatrix();
RealMatrix bbt = b.multiply(b.transpose());
for (int i = 0; i < covariance.getRowDimension(); ++i) {
for (int j = 0; j < covariance.getColumnDimension(); ++j) {
assertEquals(covariance.getEntry(i, j), bbt.getEntry(i, j), 1.0e-12);
}
}
}
public void testMeanAndCovariance() throws DimensionMismatchException {
VectorialMean meanStat = new VectorialMean(mean.length);
VectorialCovariance covStat = new VectorialCovariance(mean.length, true);
for (int i = 0; i < 5000; ++i) {
double[] v = generator.nextVector();
meanStat.increment(v);
covStat.increment(v);
}
double[] estimatedMean = meanStat.getResult();
RealMatrix estimatedCovariance = covStat.getResult();
for (int i = 0; i < estimatedMean.length; ++i) {
assertEquals(mean[i], estimatedMean[i], 0.07);
for (int j = 0; j <= i; ++j) {
assertEquals(covariance.getEntry(i, j),
estimatedCovariance.getEntry(i, j),
0.1 * (1.0 + FastMath.abs(mean[i])) * (1.0 + FastMath.abs(mean[j])));
}
}
}
@Override
public void setUp() {
try {
mean = new double[] { 0.0, 1.0, -3.0, 2.3};
RealMatrix b = MatrixUtils.createRealMatrix(4, 3);
int counter = 0;
for (int i = 0; i < b.getRowDimension(); ++i) {
for (int j = 0; j < b.getColumnDimension(); ++j) {
b.setEntry(i, j, 1.0 + 0.1 * ++counter);
}
}
RealMatrix bbt = b.multiply(b.transpose());
covariance = MatrixUtils.createRealMatrix(mean.length, mean.length);
for (int i = 0; i < covariance.getRowDimension(); ++i) {
covariance.setEntry(i, i, bbt.getEntry(i, i));
for (int j = 0; j < covariance.getColumnDimension(); ++j) {
double s = bbt.getEntry(i, j);
covariance.setEntry(i, j, s);
covariance.setEntry(j, i, s);
}
}
RandomGenerator rg = new JDKRandomGenerator();
rg.setSeed(17399225432l);
GaussianRandomGenerator rawGenerator = new GaussianRandomGenerator(rg);
generator = new CorrelatedRandomVectorGenerator(mean,
covariance,
1.0e-12 * covariance.getNorm(),
rawGenerator);
} catch (DimensionMismatchException e) {
fail(e.getMessage());
} catch (NotPositiveDefiniteMatrixException e) {
fail("not positive definite matrix");
}
}
@Override
public void tearDown() {
mean = null;
covariance = null;
generator = null;
}
private double[] mean;
private RealMatrix covariance;
private CorrelatedRandomVectorGenerator generator;
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/random/Well512aTest.java 100644 1750 1750 12313 11532241241 26672 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.random;
import org.junit.Assert;
import org.junit.Test;
public class Well512aTest {
@Test
public void testReferenceCode() {
Well512a mt = new Well512a(new int[] {
740849862, 1202665156, -199039369, -259008301, -291878969, -1164428990, -1565918811, 491009864,
-1883086670, 1383450241, 1244617256, 689006653, -1576746370, -1307940314, 1421489086, 1742094000
});
int[] refInt = {
1634813289, 1876773016, -973836208, -2130023652, -1045460084, -1834384857, 1691032973, 609714289,
2033920362, 555915483, 6680992, 1958127415, 1866469645, -1471336965, 2049178762, -192324811,
-2056050066, 810879705, 1405046309, -781317118, 1012782311, -1045081032, 728377508, 1473511660,
290489070, 326666761, 2018299979, -1876688058, 1239968501, 1464625040, 2025151042, -101397407,
1387902041, 210959839, 1366359326, -476473433, 153180037, -1607631523, -506743495, 17888738,
313865008, -340504498, 586684079, 1243699375, 753162229, -646761694, -739189655, -210120185,
-1856358726, -628255542, -1812798197, 1416288088, 1077967722, -846846208, 1379850409, -580183344,
-1858959, 210859778, 295841424, 1492774865, -1415543680, -344870570, -1942779197, 1549510646,
-389544849, 314254218, 11784988, -1311757368, 1719514841, -764610517, 1296788970, -994707050,
783854563, 422654144, 387639079, 1219688425, 2144352572, -834212874, -1036550358, 935909479,
-568610842, 1327498837, -588933178, 1910065754, -40851599, -182063170, 1302731458, 541311559,
-1647345522, 805224371, -1721196679, 1518507830, -952689880, -433276260, 509675254, -777259954,
1277810106, 284054896, 936042202, 2036836351, 1956412426, -1186403024, 287795400, 2135311211,
720485927, 1500695024, -281656583, -1277937322, -1628968482, 1242814831, -2030700974, 1473867890,
440813549, -1357033971, 28384076, 1602731216, -641465746, -609054347, 635938444, 1472898176,
1476894555, -747974186, -1590337055, -884242108, -389736197, -2066984505, 1087103272, -1236446290,
31657463, 1835715432, -468439078, -2132633204, -434609235, 258308151, 1851926761, -1630139159,
-1344617241, 1969204215, 619463174, -174392624, 207475487, -1619828078, 1327980298, -83968178,
445951782, -1786230541, 6279288, -580982231, 1550645552, 2006533941, 275746007, 455676647,
2019637349, 1115547704, -1313120106, -516213449, 73752461, -1382448112, 398589620, 1319888048,
-1595572334, 1566934536, -1735685764, -1509545339, 1458173912, -549395819, -618827040, 1516624531,
1900757187, -1454200688, 965524719, 488355065, -1869294316, -810641680, -2059428251, 1454656431,
1329120541, -232185900, -994996943, 1855980910, -452077812, 1565630611, 759842266, 1241435187,
-1390456063, 1946400597, -2032319771, 683667881, 905911106, 1983310786, 120010546, 526018017,
-1946881912, 205004987, -1307250612, 2130980818, 2052864161, 189839787, 1789478047, 406168885,
-1145186347, 8507675, 1277188815, 1492619042, 2009819675, -1627411598, -851016743, -1828234956,
1962622506, 2140398255, 236935165, -337237772, 1263419111, 516775236, -335741025, 1391328225,
455979249, -1457534664, -657606241, 485648133, 1762116343, 1194889600, 817834937, 321150162,
131159182, 290277758, -1876924740, -1770401129, 1291602973, -1003642974, -1580211929, 1520422021,
-399171579, -24315308, 453805396, -659197747, -205656847, 466526550, 1444397201, 1178091401,
-1157268826, -602394028, -1370668795, 1614896435, 1699071659, 1864753793, 1888518358, -1721244514,
1812776767, 668822227, -297283057, 2130183333, -1169618692, 912860240, -2028253096, 1244694278
};
for (int i = 0; i < refInt.length; ++i) {
Assert.assertEquals(refInt[i], mt.nextInt());
}
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/random/Well44497aTest.java 100644 1750 1750 40537 11532241241 27067 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.random;
import org.junit.Assert;
import org.junit.Test;
public class Well44497aTest {
@Test
public void testReferenceCode() {
int[] base = {
740849862, 1202665156, -199039369, -259008301, -291878969, -1164428990, -1565918811, 491009864,
-1883086670, 1383450241, 1244617256, 689006653, -1576746370, -1307940314, 1421489086, 1742094000,
-595495729, 1047766204, 1875773301, -1637793284, 1379017098, 262792705, 191880010, -251000180,
-1753047622, -972355720, 90626881, 1644693418, 1503365577, 439653419, 1806361562, 1268823869
};
int[] init = new int[1391];
for (int i = 0; i < init.length; ++i) {
init[i] = base[i % base.length] + i;
}
Well44497a mt = new Well44497a(init);
int[] refInt = {
-1464956854, -1524360321, 986845646, -182050548, -818943186, -1744848370, 1392434650, -182648505, -2026593838, 1254866610, -410459761, -1392048371, -968730026, 1485793687, -728749746, -112685463,
275126404, -1101838984, 1193096287, 443511615, -510869213, 549869992, 1974458428, -1217587840, -335835016, -2048974745, 1066947099, -611611187, 1978925459, 688164478, -463344808, 56995910,
699288809, 606392470, 117418673, 1948706703, -485598135, 385841705, 1725261146, -919553921, 70643668, 2128611684, 1720197347, 738706713, 1162026860, -611442152, 1469145601, 2051653750,
609067755, -1971782890, -971114565, 776260144, 1619791127, -1547233838, 1502505722, 913168193, 1761269649, 81782996, 62251540, 1519079156, 1239007000, 489633356, -800433470, -2107278046,
495320431, 269446836, -2013306553, 1074614697, 1645125348, 584369930, -405429577, 1211134012, -2060113546, -2047824, -443978800, 271218497, -1002185964, 1519315874, -695096464, -79101601,
-1521653608, 192426133, 1159511202, -1354494985, -477280535, 583522228, -661741458, -1251175621, -369487281, -2015449518, -2102058930, -645264919, -925270025, -1674575999, 1363844609, -831732660,
-1668989157, -1861246633, 83763283, -1056074975, -519054258, -1546386261, 1691674654, -885968657, -1189571815, 2095154843, 1686743191, -1859471265, -261593938, 1721982136, -491120252, -949699153,
642525852, -2005306625, -1004765905, 742736856, 1653443876, 788423835, 1536155740, 879514143, -1510757104, 115238646, 28600662, 1485490803, 1272460710, 523153480, -766782926, 1332478031,
528775440, 302965264, -2046891123, 1108139271, 1611601128, 550846467, -439082190, 1244786747, 941120547, -35568474, 1756370964, 304870369, 1902684028, -408710726, 1673189520, 1180987663,
-1488131864, 158973303, 154514890, -1387953397, 1453732833, -1342263302, -628153633, 4710424, 619931109, 721411332, -2135645486, 1688696681, -891749588, -1641122924, 1397432310, -865254619,
-1635468227, -1827787970, -1311416657, -1022618057, 1411688086, -1579840139, -637954674, 2115653281, -1155985079, -1043532593, -374286955, -1825883832, -227940643, 1688394137, -524577925, -983222470,
-1955769926, 626525757, -2009760930, -1855453635, -676923169, 754966926, -291202391, -2126042921, -1477304277, -1409345382, -1264640578, -441993991, -17611930, -1576809974, 2137694350, 1299022733,
-762509116, -1087399293, 819303572, -14571174, -719035481, -1644675278, 1492736905, -15038081, 974773023, 1087127339, 1790024863, -1493135734, 1936273291, -442361741, 1639666948, 1147532756,
174955156, -1537685747, 187972574, 275303083, 1420277149, -1375787574, 1873043153, 38164241, 653451946, 687758113, 899667071, 1722219976, 2146668333, 587401069, -26582672, 2034645447,
1401801794, 1043291001, -1277898614, 2116116828, 1445274301, 150534325, 469242183, -937704471, 171074779, -204638071, 1269913689, -771734064, -12280461, -1182158859, 1704390140, -263303749,
-848503723, -1822849148, -634064465, 1130988864, -1515750310, -908815400, 1487214333, 994482967, 853103628, 1711185413, 1520342001, 1067859186, 1693632130, -603831333, 292236742, -800655385,
-1467184928, 221125007, -1697377800, 1293953144, 1730537111, 1073329737, 519625212, 689636032, 1127394154, -1496469136, -1214585810, 822152197, -1572579275, -527866383, -996792678, -2058452887,
-1133767559, 576275042, 1579109209, -295089371, 1502267384, -724281876, -911879875, 1131096177, 333026744, 1238706603, 1067340063, -745697708, -973992204, 1560446744, -664017057, -616056490,
1099714049, 674159948, 383625825, 1411443110, 1862818263, -1896254899, 1322476914, -719144734, -1540101945, 988154902, 781856577, 2013381051, -2059071359, -142073207, 60252832, 2052050421,
-666391497, 376633738, 1663011481, -1706886481, -1870003191, 1003819645, 898131216, 778824906, -656875645, -1730811011, -1751653787, 2056079904, 231977636, 1831419220, -465545074, -1505266471,
1034419975, -133864043, 1876779821, 1879792902, -100100435, -959264741, -472668436, 203584096, -46980157, -1478047098, -979669209, 809008494, 1279644171, 2055793632, 1385672419, -1756428826,
-1790481031, -2089665073, -1608595011, 457322987, 1267418945, -19541848, -796352273, -1049973752, 30940894, -539710199, -1097391703, -779353550, -1328320498, -735447662, -918513196, 1516945649,
1218919237, -251287485, 1826366637, 353082340, 889839220, 399638904, -1462573609, -618450466, 1429903706, 2095548034, 1486594475, -1053248922, 74346322, -357998703, 1790710495, -146359619,
1581657509, -797737661, -920778913, 608399665, 646679359, 1861775150, -1014371223, 476735306, -1577737028, 383018939, 1234592859, 344770283, -472763155, 187217985, 1245828866, 1936329359,
61243025, -1979390025, 903671173, 302699505, -1677126111, -1194113496, 835857595, 706998946, 70931462, 1374113464, -1464459699, -231081598, 1366205112, 396990527, -1615015619, -968458597,
457632575, 24361353, -1120685182, 2101590608, 1654666456, -1208442054, 579414359, 1078056578, 217408674, -1560683025, 815178420, 1219326466, 450032327, 774403237, 54597342, -664057229,
447132403, 50603973, 435640301, -1224073863, -1339908037, 1775470944, -1378119263, -1375189988, -1287971162, 29816317, -1313418882, -1824967031, 443540716, 11064217, -1463969487, 1967601549,
124474667, 1230898256, -1741455555, 561643750, 933295231, -923145874, 245538199, 289478386, 200552280, -268887021, -1598221376, 1236123270, 318325803, 773964550, 191670680, 158043961,
-762639146, -416703928, -721969492, 1664330785, -584949010, 1509045840, -2066001147, 1728613092, -1103375821, -1262079070, -2034789427, -418216342, -546365126, 1235751589, 1639799329, 2085089663,
-697590049, -2007054256, -147701903, 209371702, -1868450893, 1241065116, 1537364837, -1035970557, 318040217, 150492098, 1841159805, -491979749, -1275490577, -1759443566, -697538216, -1589624976,
-678703557, -189067001, 1539472677, -1396089831, 271512148, 180483983, 483714313, 703861378, 2122114992, -600097045, 522009268, 160429181, -744428886, 1541223403, -1211039718, -1167643980,
1551471162, -816207368, -1429258613, 1350901561, 1934120609, -961643277, -214772286, -2128270227, -1561239720, 1493926966, 1376671007, 94966082, 221846150, -164351411, -51309876, 497148497,
1233668542, 266257753, -773473851, 953946385, 420815294, -1390653175, 1834391782, 4704447, -891751440, -744104272, -1082756642, 1431640408, -1912055536, -159789461, -704946016, 1956368139,
642279822, -374415338, 1562655802, -272964020, 1071498305, 667364168, -1546405154, 341389690, 1360662999, 377696332, -437020076, -1668574556, 1242655350, -756555890, 645954261, 1914624235,
2134904445, -247737098, 143667521, -17668806, 1804148531, 414247300, 1030053929, -1595215075, 887532426, 553113691, 1173830167, -303724353, -280418143, -1143962122, -1898518451, 36464746,
1189572700, -1549967582, 1093341440, -452303819, -731023001, 1111173883, 1678013973, -836458212, -842956392, 212774049, -845621791, 966282353, -823130040, 700410571, 619075141, -304785045,
-1816233676, -1789653997, -166914694, 690663021, -669570330, 1098624444, -987380984, 452844935, -1089825546, 1221160503, 1217375341, 512281644, -1106887134, 1665404458, -1462594714, -207498587,
-789271490, -723469709, 512055365, 1445951882, 1692473633, -996873493, 1445046730, 993087194, -1666188562, -897427329, 1008869698, 1236029718, 1499207233, 1704947182, -1815799281, 686399988,
-475436580, 1588892458, 884859588, -471913926, -487416631, 1323960741, -1257612174, -468909314, -1866654496, -1417895838, 1707647971, 997140465, -1358794225, 1929422460, -605622778, -1587468566,
469149623, 1121515927, 748484204, 1201983830, -1906623591, 76398473, 261109068, -796025669, -1964466661, 1739898262, -756850622, 1581369453, 1484675811, 484136467, -705983890, -1357931714,
548520423, 741992908, 1017931838, -2078503520, 2097871343, 569233897, -91903627, 1864053450, -876129714, 336670307, -1950420274, -872316480, -662220291, 275724295, 703565412, 1334248646,
-217559198, 1044090753, 743502488, -1518545318, 20614180, -768582053, 976522354, -25129962, -983639284, 71722595, -119236393, 368844119, -795808244, 696073964, 1379765302, 235083623,
666280330, -1313689346, -643870520, 534522699, -250414377, -1239276164, 159264592, -1119503518, 1168161619, -1366518946, -1335653301, 248092140, 1390152547, 2051602724, -1023547981, -1479782621,
-1785785862, 1609789158, -919124123, 1703200068, -852553456, 1573706142, -376011685, 305068766, -1231775451, -1536883494, -125122369, -896696968, 852651567, -458154391, 747781704, 1173040469,
-1569200836, 312506093, -1680530410, 117086271, 794587661, -1231003908, -1048955503, 2119305423, 1636729108, -522378372, 1627421730, 545077470, -1683264872, 1486496559, -1793064672, 1908368749,
-1226052295, 1399248776, -588193954, -1289386125, 534647065, 2126245059, -238362987, -1244573058, -1571832269, -2052693379, 1494767731, -528668449, -980826491, -151282847, -1468523556, 1876349941,
-301654558, 1467960576, -741720848, -612158589, 92376910, 987915105, 1037689578, 793773489, -1387669541, 349490139, 564784004, -1161242130, 619703053, 2063233129, 190888106, 81845991,
-1482466066, 283234313, 114355492, -1879406787, -1283370924, -1378903370, -730141747, 1570738286, -281348873, 2131743196, 795654462, -497365688, 437612465, 1928618254, 1433118279, -1801292119,
-2059248836, -221673230, 163637697, -411319468, 244353317, 786753178, 489172932, 464627154, 1258915212, -229028334, -994675463, 1931657329, 1784181437, -97111947, 1728952452, -1329133577,
-1606156362, 1341196121, 1679632329, -796545286, -1021125869, 1427825468, -214986389, 250791528, 1029777000, 90661677, 602529506, 2068040879, 1483801763, 2332097, -457467017, 672399614,
1542769193, 1781253216, -1967165705, -2052227925, -1248173215, -1676554121, 292413596, 209649573, 1750689340, 1946874730, -832845570, 1774178655, -450175610, -431901779, 613330756, 1969434259,
1251099237, -1320908513, -50659188, 273178515, -296290724, 1195998469, 1329813722, 759419114, 1003396150, -274557619, -548886303, -2055397788, -766678640, -464045978, -1835907569, -169406709,
820751456, 1778613303, -1582073956, -1728391771, -2075389498, -1606584632, -1702107251, -15724560, 45610235, -1967510298, -671487775, -1841110041, -913365944, 869680052, -798103472, -1564096927,
-918899909, -810066882, 428829752, -1413487973, -844240890, 1343914280, -689285374, 1827745702, -799686631, 1696465705, -726159000, -1381157526, 1649221296, 1791106481, -1872852642, -485685063,
1534949133, -1611901907, -581776031, 242740701, -382394666, 668419384, 388297992, 748818886, 713804061, -1783774172, -1823401590, -1009098384, 2071462929, 1154475522, 1309810666, -1734475040,
1212095416, 988288210, -1457428115, 1699730041, -1804729443, -1922824494, 1000076038, -226555981, 131425181, -1071582828, 357680377, 1574190179, 996651958, 965704429, -47651768, 243931978,
808955117, -652323633, 544967309, -1199510217, 702795379, 997685748, 1593927308, 2119371055, 1451401230, -41992913, 2033816081, -1030495962, 1764010175, 457470691, -2001190141, -373358035,
-1950331268, -1291674220, 642934467, -1825725718, -1555687487, 1664472129, -24722338, 1899539596, 78519318, 1662555805, 1744711308, -2142888582, -1597853572, 118030659, 1596713428, 404304267,
-1350880388, 648702031, 1185458591, 1798138033, 819516445, -1466759682, -751277607, -879817426, -1931050435, 1465603177, -1402344216, 768491239, -1404853657, -1915685264, -1845859847, 313163207,
1239598382, 1988767047, -555152530, -1925665864, -182399255, -1392390808, 64861291, -511875035, 1879964459, 918905020, -840773616, 459610189, -1522352470, -1821396360, 977274705, -60616465,
-1846727880, 1208592937, -515359427, 1127607806, -395032287, 491869604, 2053794084, 568321750, 1597027438, 1355613070, -2069482724, 1899252555, 844726247, -625112193, 1146099491, -1037855139,
1203928737, 1875686061, 994108281, 1471873396, 2026801570, 4941446, -1066074241, -983738686, 2037429697, -836521112, -633388883, 1221918725, 2137035208, -369891832, 372509548, -110916409,
80517712, -658056946, 727893428, -1353651002, -475459562, -291323023, 1059377566, 591801919, 1018232602, -348255729, 1863827426, 246032476, -1026132864, -1356383176, -1224690998, 262442981,
1257773681, -1738604660, 77131430, -1320261233, -2342727, -1817187590, -1883997191, 1367221809, -1863623746, -1132606249, 149024763, -1228275128, -578030399, 356914163, 2109691820, -880313621
};
for (int i = 0; i < refInt.length; ++i) {
Assert.assertEquals(refInt[i], mt.nextInt());
}
}
}
commons-math-2.2-src/src/test/java/org/apache/commons/math/random/AbstractRandomGeneratorTest.java 100644 1750 1750 11256 11532241241 32156 0 ustar luc luc 0 0 /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.random;
import org.apache.commons.math.stat.Frequency;
/**
* Test cases for the AbstractRandomGenerator class
*
* @version $Revision: 902201 $ $Date: 2010-01-22 19:18:16 +0100 (ven. 22 janv. 2010) $
*/
public class AbstractRandomGeneratorTest extends RandomDataTest {
protected TestRandomGenerator testGenerator = new TestRandomGenerator();
public AbstractRandomGeneratorTest(String name) {
super(name);
randomData = new RandomDataImpl(testGenerator);
}
@Override
public void testNextInt() {
try {
testGenerator.nextInt(-1);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// ignored
}
Frequency freq = new Frequency();
int value = 0;
for (int i=0; i= 0) && (value <= 3));
freq.addValue(value);
}
long[] observed = new long[4];
for (int i=0; i<4; i++) {
observed[i] = freq.getCount(i);
}
/* Use ChiSquare dist with df = 4-1 = 3, alpha = .001
* Change to 11.34 for alpha = .01
*/
assertTrue("chi-square test -- will fail about 1 in 1000 times",
testStatistic.chiSquare(expected,observed) < 16.27);
}
@Override
public void testNextLong() {
long q1 = Long.MAX_VALUE/4;
long q2 = 2 * q1;
long q3 = 3 * q1;
Frequency freq = new Frequency();
long val = 0;
int value = 0;
for (int i=0; i