use of org.hipparchus.distribution.RealDistribution in project symja_android_library by axkr.
the class PDF method evaluateNumericMode.
private IExpr evaluateNumericMode(IAST dist, IExpr xArg, ISymbol head) {
try {
RealDistribution realDistribution;
IntegerDistribution intDistribution;
if (dist.isAST1()) {
if (head.equals(F.BernoulliDistribution)) {
} else if (head.equals(F.PoissonDistribution)) {
int n = ((ISignedNumber) dist.arg1()).toInt();
int k = ((ISignedNumber) xArg).toInt();
intDistribution = new org.hipparchus.distribution.discrete.PoissonDistribution(n);
return F.num(intDistribution.probability(k));
}
} else if (dist.isAST2()) {
if (head.equals(F.BinomialDistribution)) {
int n = ((ISignedNumber) dist.arg1()).toInt();
double p = ((ISignedNumber) dist.arg2()).doubleValue();
int k = ((ISignedNumber) xArg).toInt();
intDistribution = new org.hipparchus.distribution.discrete.BinomialDistribution(n, p);
return F.num(intDistribution.probability(k));
} else if (head.equals(F.NormalDistribution)) {
double mean = ((ISignedNumber) dist.arg1()).doubleValue();
double stdDev = ((ISignedNumber) dist.arg2()).doubleValue();
double x = ((ISignedNumber) xArg).doubleValue();
realDistribution = new org.hipparchus.distribution.continuous.NormalDistribution(mean, stdDev);
return F.num(realDistribution.density(x));
}
} else if (dist.isAST3()) {
if (head.equals(F.HypergeometricDistribution)) {
int n = ((ISignedNumber) dist.arg1()).toInt();
int nSucc = ((ISignedNumber) dist.arg2()).toInt();
int nTot = ((ISignedNumber) dist.arg3()).toInt();
int k = ((ISignedNumber) xArg).toInt();
intDistribution = new org.hipparchus.distribution.discrete.HypergeometricDistribution(nTot, nSucc, n);
return F.num(intDistribution.probability(k));
}
}
} catch (ArithmeticException ae) {
} catch (ClassCastException cca) {
}
return F.NIL;
}
use of org.hipparchus.distribution.RealDistribution in project symja_android_library by axkr.
the class CDF method evaluateNumericMode.
private IExpr evaluateNumericMode(IAST dist, IExpr xArg, ISymbol head) {
try {
RealDistribution realDistribution;
IntegerDistribution intDistribution;
if (dist.isAST1()) {
if (head.equals(F.BernoulliDistribution)) {
} else if (head.equals(F.PoissonDistribution)) {
int n = ((ISignedNumber) dist.arg1()).toInt();
int k = ((ISignedNumber) xArg).toInt();
}
} else if (dist.isAST2()) {
if (head.equals(F.BinomialDistribution)) {
int n = ((ISignedNumber) dist.arg1()).toInt();
double p = ((ISignedNumber) dist.arg2()).doubleValue();
int k = ((ISignedNumber) xArg).toInt();
} else if (head.equals(F.NormalDistribution)) {
double mean = ((ISignedNumber) dist.arg1()).doubleValue();
double stdDev = ((ISignedNumber) dist.arg2()).doubleValue();
double x = ((ISignedNumber) xArg).doubleValue();
}
} else if (dist.isAST3()) {
if (head.equals(F.HypergeometricDistribution)) {
int n = ((ISignedNumber) dist.arg1()).toInt();
int nSucc = ((ISignedNumber) dist.arg2()).toInt();
int nTot = ((ISignedNumber) dist.arg3()).toInt();
int k = ((ISignedNumber) xArg).toInt();
}
}
} catch (ArithmeticException ae) {
} catch (ClassCastException cca) {
}
return F.NIL;
}
Aggregations