BetaDistribution extends AbstractRealDistribution { public double density(double x) { final double logDensity = logDensity(x); return logDensity == Double.NEGATIVE_INFINITY ? 0 : FastMath.exp(logDensity); } BetaDistribution(double alpha, double beta);  BetaDistribution(double alpha, double beta, double inverseCumAccuracy);  BetaDistribution(RandomGenerator rng, double alpha, double beta);  BetaDistribution(RandomGenerator rng,
                            double alpha,
                            double beta,
                            double inverseCumAccuracy); double getAlpha(); double getBeta(); double density(double x); @Override double logDensity(double x); double cumulativeProbability(double x); double getNumericalMean(); double getNumericalVariance(); double getSupportLowerBound(); double getSupportUpperBound(); boolean isSupportLowerBoundInclusive(); boolean isSupportUpperBoundInclusive(); boolean isSupportConnected(); static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY; }
@Test public void testDensity() { double[] x = new double[]{1e-6, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9}; checkDensity(0.1, 0.1, x, new double[]{ 12741.2357380649, 0.4429889586665234, 2.639378715e-01, 2.066393611e-01, 1.832401831e-01, 1.766302780e-01, 1.832404579e-01, 2.066400696e-01, 2.639396531e-01, 4.429925026e-01}); checkDensity(0.1, 0.5, x, new double[]{ 2.218377102e+04, 7.394524202e-01, 4.203020268e-01, 3.119435533e-01, 2.600787829e-01, 2.330648626e-01, 2.211408259e-01, 2.222728708e-01, 2.414013907e-01, 3.070567405e-01}); checkDensity(0.1, 1.0, x, new double[]{ 2.511886432e+04, 7.943210858e-01, 4.256680458e-01, 2.955218303e-01, 2.281103709e-01, 1.866062624e-01, 1.583664652e-01, 1.378514078e-01, 1.222414585e-01, 1.099464743e-01}); checkDensity(0.1, 2.0, x, new double[]{ 2.763072312e+04, 7.863770012e-01, 3.745874120e-01, 2.275514842e-01, 1.505525939e-01, 1.026332391e-01, 6.968107049e-02, 4.549081293e-02, 2.689298641e-02, 1.209399123e-02}); checkDensity(0.1, 4.0, x, new double[]{ 2.997927462e+04, 6.911058917e-01, 2.601128486e-01, 1.209774010e-01, 5.880564714e-02, 2.783915474e-02, 1.209657335e-02, 4.442148268e-03, 1.167143939e-03, 1.312171805e-04}); checkDensity(0.5, 0.1, x, new double[]{ 88.3152184726, 0.3070542841, 0.2414007269, 0.2222727015, 0.2211409364, 0.2330652355, 0.2600795198, 0.3119449793, 0.4203052841, 0.7394649088}); checkDensity(0.5, 0.5, x, new double[]{ 318.3100453389, 1.0610282383, 0.7957732234, 0.6946084565, 0.6497470636, 0.6366197724, 0.6497476051, 0.6946097796, 0.7957762075, 1.0610376697}); checkDensity(0.5, 1.0, x, new double[]{ 500.0000000000, 1.5811309244, 1.1180311937, 0.9128694077, 0.7905684268, 0.7071060741, 0.6454966865, 0.5976138778, 0.5590166450, 0.5270459839}); checkDensity(0.5, 2.0, x, new double[]{ 749.99925000000, 2.134537420613655, 1.34163575536, 0.95851150881, 0.71151039830, 0.53032849490, 0.38729704363, 0.26892534859, 0.16770415497, 0.07905610701}); checkDensity(0.5, 4.0, x, new double[]{ 1.093746719e+03, 2.52142232809988, 1.252190241e+00, 6.849343920e-01, 3.735417140e-01, 1.933481570e-01, 9.036885833e-02, 3.529621669e-02, 9.782644546e-03, 1.152878503e-03}); checkDensity(1.0, 0.1, x, new double[]{ 0.1000000900, 0.1099466942, 0.1222417336, 0.1378517623, 0.1583669403, 0.1866069342, 0.2281113974, 0.2955236034, 0.4256718768, 0.7943353837}); checkDensity(1.0, 0.5, x, new double[]{ 0.5000002500, 0.5270465695, 0.5590173438, 0.5976147315, 0.6454977623, 0.7071074883, 0.7905704033, 0.9128724506, 1.1180367838, 1.5811467358}); checkDensity(1, 1, x, new double[]{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}); checkDensity(1, 2, x, new double[]{ 1.999998, 1.799998, 1.599998, 1.399998, 1.199998, 0.999998, 0.799998, 0.599998, 0.399998, 0.199998}); checkDensity(1, 4, x, new double[]{ 3.999988000012, 2.915990280011, 2.047992320010, 1.371994120008, 0.863995680007, 0.499997000006, 0.255998080005, 0.107998920004, 0.031999520002, 0.003999880001}); checkDensity(2.0, 0.1, x, new double[]{ 1.100000990e-07, 1.209425730e-02, 2.689331586e-02, 4.549123318e-02, 6.968162794e-02, 1.026340191e-01, 1.505537732e-01, 2.275534997e-01, 3.745917198e-01, 7.863929037e-01}); checkDensity(2.0, 0.5, x, new double[]{ 7.500003750e-07, 7.905777599e-02, 1.677060417e-01, 2.689275256e-01, 3.872996256e-01, 5.303316769e-01, 7.115145488e-01, 9.585174425e-01, 1.341645818e+00, 2.134537420613655}); checkDensity(2, 1, x, new double[]{ 0.000002, 0.200002, 0.400002, 0.600002, 0.800002, 1.000002, 1.200002, 1.400002, 1.600002, 1.800002}); checkDensity(2, 2, x, new double[]{ 5.9999940e-06, 5.4000480e-01, 9.6000360e-01, 1.2600024e+00, 1.4400012e+00, 1.5000000e+00, 1.4399988e+00, 1.2599976e+00, 9.5999640e-01, 5.3999520e-01}); checkDensity(2, 4, x, new double[]{ 0.00001999994, 1.45800971996, 2.04800255997, 2.05799803998, 1.72799567999, 1.24999500000, 0.76799552000, 0.37799676001, 0.12799824001, 0.01799948000}); checkDensity(4.0, 0.1, x, new double[]{ 1.193501074e-19, 1.312253162e-04, 1.167181580e-03, 4.442248535e-03, 1.209679109e-02, 2.783958903e-02, 5.880649983e-02, 1.209791638e-01, 2.601171405e-01, 6.911229392e-01}); checkDensity(4.0, 0.5, x, new double[]{ 1.093750547e-18, 1.152948959e-03, 9.782950259e-03, 3.529697305e-02, 9.037036449e-02, 1.933508639e-01, 3.735463833e-01, 6.849425461e-01, 1.252205894e+00, 2.52142232809988}); checkDensity(4, 1, x, new double[]{ 4.000000000e-18, 4.000120001e-03, 3.200048000e-02, 1.080010800e-01, 2.560019200e-01, 5.000030000e-01, 8.640043200e-01, 1.372005880e+00, 2.048007680e+00, 2.916009720e+00}); checkDensity(4, 2, x, new double[]{ 1.999998000e-17, 1.800052000e-02, 1.280017600e-01, 3.780032400e-01, 7.680044800e-01, 1.250005000e+00, 1.728004320e+00, 2.058001960e+00, 2.047997440e+00, 1.457990280e+00}); checkDensity(4, 4, x, new double[]{ 1.399995800e-16, 1.020627216e-01, 5.734464512e-01, 1.296547409e+00, 1.935364838e+00, 2.187500000e+00, 1.935355162e+00, 1.296532591e+00, 5.734335488e-01, 1.020572784e-01}); }