Search in sources :

Example 1 with RealDistribution

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;
}
Also used : RealDistribution(org.hipparchus.distribution.RealDistribution) ISignedNumber(org.matheclipse.core.interfaces.ISignedNumber) IntegerDistribution(org.hipparchus.distribution.IntegerDistribution)

Example 2 with RealDistribution

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;
}
Also used : ISignedNumber(org.matheclipse.core.interfaces.ISignedNumber) IntegerDistribution(org.hipparchus.distribution.IntegerDistribution) RealDistribution(org.hipparchus.distribution.RealDistribution)

Aggregations

IntegerDistribution (org.hipparchus.distribution.IntegerDistribution)2 RealDistribution (org.hipparchus.distribution.RealDistribution)2 ISignedNumber (org.matheclipse.core.interfaces.ISignedNumber)2