本文整理汇总了Java中cern.jet.stat.Probability类的典型用法代码示例。如果您正苦于以下问题:Java Probability类的具体用法?Java Probability怎么用?Java Probability使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Probability类属于cern.jet.stat包,在下文中一共展示了Probability类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeMissingParameterAfterSim
import cern.jet.stat.Probability; //导入依赖的package包/类
@Override
public void computeMissingParameterAfterSim()
{
// Only compute for numSamples > 1
// (Student's t-distribution only defined for v > 0)
if (numSamples > 1) {
double prob, x;
x = width * Math.sqrt(numSamples / varEstimator);
// Note: need to hard-code case x=Inf
if (Double.isInfinite(x)) {
prob = 1.0;
}
// (Note: Colt's studentT seems to break for v=1 so do manually)
else if (numSamples - 1 > 1) {
prob = Probability.studentT(x, numSamples - 1);
} else {
// PDF for v=1 is 1/2 + arctan(x)/pi
prob = 0.5 + Math.atan(x) / Math.PI;
}
confidence = 2 * (1.0 - prob);
missingParameterComputed = true;
}
}
示例2: computeMissingParameterAfterSim
import cern.jet.stat.Probability; //导入依赖的package包/类
@Override
public void computeMissingParameterAfterSim()
{
double quantile;
// Only compute for numSamples > 1
// (Student's t-distribution only defined for v > 0)
if (numSamples > 1) {
// (Note: Colt's studentTinverse seems to break for v=1 so do manually)
if (numSamples - 1 > 1) {
quantile = Probability.studentTInverse(confidence, numSamples - 1);
} else {
// PDF for v=1 is 1/2 + arctan(x)/pi
// Want x for pdf = 1-conf/2
quantile = Math.tan((0.5 - confidence / 2) * Math.PI);
}
width = quantile * Math.sqrt(varEstimator / numSamples);
missingParameterComputed = true;
}
}
示例3: binomialSampleEquality
import cern.jet.stat.Probability; //导入依赖的package包/类
protected double binomialSampleEquality(double X1, double X2, double n1, double n2){
double P1 = X1/n1;
double P2 = X2/n2;
double P = (X1+X2)/(n1+n2);
double Z = (P1-P2)/(Math.sqrt(P*(1-P)*((1/n1)+(1/n2))));
if(!Double.isNaN(Z))
return(1-Probability.normal(Z));
else
return(-1);
}
示例4: shouldStopNow
import cern.jet.stat.Probability; //导入依赖的package包/类
@Override
public boolean shouldStopNow(int iters, Sampler sampler)
{
double quantile = 0.0;
// Need at least 2 iterations
// (Student's t-distribution only defined for v > 1)
// (and variance is always 0 for iters = 1)
if (iters < 2)
return false;
// We cannot conclude yet whether it is a "S^2=0" case or if the estimator is still valid (i.e. std error > 0)
if (sampler.getVariance() <= 0.0) {
// automatic
if (!reqIterToConcludeGiven && maxReward / width > iters)
return false;
// "manual"
if (reqIterToConcludeGiven && reqIterToConclude > iters)
return false;
}
// The required number of iterations for the expected confidence is not reached yet
quantile = Probability.normalInverse(1.0 - confidence / 2.0);
squaredQuantile = quantile * quantile;
if (sampler.getVariance() > 0.0 && (iters + 1) < sampler.getVariance() * squaredQuantile / (width * width))
return false;
// Store final number of iterations (to compute missing parameter later)
computedIterations = iters;
return true;
}
示例5: shouldStopNow
import cern.jet.stat.Probability; //导入依赖的package包/类
@Override
public boolean shouldStopNow(int iters, Sampler sampler)
{
double quantile = 0.0;
// Need at least 2 iterations
// (Student's t-distribution only defined for v > 0)
// (and variance is always 0 for iters = 1)
if (iters < 2)
return false;
// We cannot conclude yet whether it is a "S^2=0" case or if the estimator is still valid (i.e. std error > 0)
if (sampler.getVariance() <= 0.0) {
// automatic
if (!reqIterToConcludeGiven && maxReward / width > iters)
return false;
// "manual"
if (reqIterToConcludeGiven && reqIterToConclude > iters)
return false;
}
// See if required number of iterations for the expected confidence is reached yet
// (Note: Colt's studentTinverse seems to break for v=1 so do manually)
if (iters - 1 > 1) {
quantile = Probability.studentTInverse(confidence, iters - 1);
} else {
// PDF for v=1 is 1/2 + arctan(x)/pi
// Want x for pdf = 1-conf/2
quantile = Math.tan((0.5 - confidence / 2) * Math.PI);
}
squaredQuantile = quantile * quantile;
if (sampler.getVariance() > 0.0 && iters < sampler.getVariance() * squaredQuantile / (width * width))
return false;
// Store final number of iterations (to compute missing parameter later)
computedIterations = iters;
return true;
}
示例6: getInverseCDF
import cern.jet.stat.Probability; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public double getInverseCDF(final Double p) {
Validate.notNull(p);
Validate.isTrue(p >= 0 && p <= 1, "Probability must be >= 0 and <= 1");
return Probability.normalInverse(p);
}
示例7: pValueForTstat
import cern.jet.stat.Probability; //导入依赖的package包/类
public static double pValueForTstat(double tstat, int df)
throws ExtensionException {
// Returns the P value of the T statistic tstat with df degrees of
// freedom. This is a two-tailed test so we just double the right
// tail which is given by studentT of -|tstat|.
double x = Math.abs(tstat);
try {
double p = Probability.studentT((double) df, -x);
return 2.0 * p;
} catch (IllegalArgumentException | ArithmeticException ex) {
throw new ExtensionException("colt .studentT reports: " + ex);
}
}
示例8: getStudentArea
import cern.jet.stat.Probability; //导入依赖的package包/类
public static double getStudentArea(double x, int df)
throws ExtensionException {
// Returns the area to the left of x in the Student T distribution
// with the given degrees of freedom.
try {
return Probability.studentT((double) df, x);
} catch (IllegalArgumentException | ArithmeticException ex) {
throw new ExtensionException("colt .studentT reports: " + ex);
}
}
示例9: getNormalArea
import cern.jet.stat.Probability; //导入依赖的package包/类
public static double getNormalArea(double x, double mean, double sd)
throws ExtensionException {
// Returns the area to the left of x in the normal distribution
// with the given mean and standard deviation.
try {
return Probability.normal(mean, sd, x);
} catch (IllegalArgumentException | ArithmeticException ex) {
throw new ExtensionException("colt .normal reports: " + ex);
}
}
示例10: getStudentTInverse
import cern.jet.stat.Probability; //导入依赖的package包/类
public static double getStudentTInverse(double x, int df)
throws ExtensionException {
// Returns the value, t, for which the area under the Student-t
// probability density function (integrated from minus infinity to t)
// is equal to x.
double a = 2.0 * (1.0 - x);
try {
return Probability.studentTInverse(a, df);
} catch (IllegalArgumentException | ArithmeticException ex) {
throw new ExtensionException("colt .studentTInverse reports: " + ex);
}
}
示例11: getNormalInverse
import cern.jet.stat.Probability; //导入依赖的package包/类
public static double getNormalInverse(double area, double mean, double sd)
throws ExtensionException {
// Returns the x in the normal distribution with the given mean and
// standard deviation, to the left of which lies the given area.
// normal.Inverse returns the value in terms of standard deviations
// from the mean, so we need to adjust it for the given mean and
// standard deviation.
try {
double x = Probability.normalInverse(area);
return (x + mean) * sd;
} catch (IllegalArgumentException | ArithmeticException ex) {
throw new ExtensionException("colt .normalInverse reports: " + ex);
}
}
示例12: getBinomialComplemented
import cern.jet.stat.Probability; //导入依赖的package包/类
public static double getBinomialComplemented(int n, int k, double p)
throws ExtensionException {
// Returns the sum of the terms k+1 through n of the Binomial
// probability density, where n is the number of trials and P is
// the probability of success in the range 0 to 1.
try {
return Probability.binomialComplemented(k, n, p);
} catch (IllegalArgumentException | ArithmeticException ex) {
throw new ExtensionException("colt .binomialComplement reports: " + ex);
}
}
示例13: getChiSquare
import cern.jet.stat.Probability; //导入依赖的package包/类
public static double getChiSquare(double x, double df)
throws ExtensionException {
// Returns the area under the left hand tail (from 0 to x) of the
// Chi square probability density function with df degrees of freedom.
try {
return Probability.chiSquare(df, x);
} catch (IllegalArgumentException | ArithmeticException ex) {
throw new ExtensionException("colt .chiSquare reports: " + ex);
}
}
示例14: getChiSquareComplemented
import cern.jet.stat.Probability; //导入依赖的package包/类
public static double getChiSquareComplemented(double x, double df)
throws ExtensionException {
// Returns the area under the right hand tail (from x to infinity)
// of the Chi square probability density function with df degrees
// of freedom.
try {
return Probability.chiSquareComplemented(df, x);
} catch (IllegalArgumentException | ArithmeticException ex) {
throw new ExtensionException("colt .chiSquareComplemented reports: " + ex);
}
}
示例15: binomialSampleEquality
import cern.jet.stat.Probability; //导入依赖的package包/类
protected double binomialSampleEquality(double X1, double X2, double n1, double n2){
double P1 = X1/n1;
double P2 = X2/n2;
double P = (X1+X2)/(n1+n2);
double Z = (P1-P2)/(Math.sqrt(P*(1-P)*((1/n1)+(1/n2))));
if(!Double.isNaN(Z)){
double prob = Probability.normal(Z);
if(prob>0.5)
return(1-prob);
else
return(prob);
}else{
return(-1);
}
}