// Absolute moment k of Gaussian distribution with mean 0 and stddev 1 is // pow(2.0,k/2.0)*gamma((k+1)/2.0)/sqrt(PI) // https://arxiv.org/pdf/1209.4340.pdf, equation (18)
staticvoid testMomentsGaussian(DoubleSupplier theSupplier) { int m = absoluteMomentsGaussian.length; double[] absoluteMoments = newdouble[m]; for (int j = 0; j < SEQUENCE_SIZE; j++) { double v = theSupplier.getAsDouble(); double z = 1.0; for (int k = 0; k < m; k++) {
absoluteMoments[k] += Math.abs(z);
z *= v;
}
} for (int k = 0; k < m; k++) {
absoluteMoments[k] /= SEQUENCE_SIZE;
}
checkMoments("Gaussian", absoluteMoments, absoluteMomentsGaussian);
}
staticvoid testMomentsExponential(DoubleSupplier theSupplier) { int m = momentsExponential.length; double[] moments = newdouble[m]; for (int j = 0; j < SEQUENCE_SIZE; j++) { double v = theSupplier.getAsDouble(); double z = 1.0; for (int k = 0; k < m; k++) {
moments[k] += z;
z *= v;
}
} for (int k = 0; k < m; k++) {
moments[k] /= SEQUENCE_SIZE;
}
checkMoments("Exponential", moments, momentsExponential);
}
staticvoid testMomentsUniform(DoubleSupplier theSupplier) { int m = momentsUniform.length; double[] moments = newdouble[m]; for (int j = 0; j < SEQUENCE_SIZE; j++) { double v = theSupplier.getAsDouble(); double z = 1.0; for (int k = 0; k < m; k++) {
moments[k] += z;
z *= v;
}
} for (int k = 0; k < m; k++) {
moments[k] /= SEQUENCE_SIZE;
}
checkMoments("Uniform", moments, momentsUniform);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.