mirror of
https://github.com/apache/commons-math.git
synced 2025-02-10 20:15:54 +00:00
Fixed missing javadoc.
This commit is contained in:
parent
b313ae6888
commit
c8cb752431
@ -310,6 +310,11 @@ public class BetaDistribution extends AbstractRealDistribution {
|
||||
|
||||
/**
|
||||
* Returns one sample using Cheng's BB algorithm, when both α and β are greater than 1.
|
||||
* @param random random generator to use
|
||||
* @param a0 distribution first shape parameter (α)
|
||||
* @param a min(α, β) where α, β are the two distribution shape parameters
|
||||
* @param b max(α, β) where α, β are the two distribution shape parameters
|
||||
* @return sampled value
|
||||
*/
|
||||
private static double algorithmBB(RandomGenerator random,
|
||||
final double a0,
|
||||
@ -319,7 +324,9 @@ public class BetaDistribution extends AbstractRealDistribution {
|
||||
final double beta = FastMath.sqrt((alpha - 2.) / (2. * a * b - alpha));
|
||||
final double gamma = a + 1. / beta;
|
||||
|
||||
double r, w, t;
|
||||
double r;
|
||||
double w;
|
||||
double t;
|
||||
do {
|
||||
final double u1 = random.nextDouble();
|
||||
final double u2 = random.nextDouble();
|
||||
@ -344,6 +351,11 @@ public class BetaDistribution extends AbstractRealDistribution {
|
||||
|
||||
/**
|
||||
* Returns one sample using Cheng's BC algorithm, when at least one of α and β is smaller than 1.
|
||||
* @param random random generator to use
|
||||
* @param a0 distribution first shape parameter (α)
|
||||
* @param a max(α, β) where α, β are the two distribution shape parameters
|
||||
* @param b min(α, β) where α, β are the two distribution shape parameters
|
||||
* @return sampled value
|
||||
*/
|
||||
private static double algorithmBC(RandomGenerator random,
|
||||
final double a0,
|
||||
|
@ -307,11 +307,20 @@ public class ZipfDistribution extends AbstractIntegerDistribution {
|
||||
/** Cached tail weight of instrumental distribution used for rejection sampling */
|
||||
private double instrumentalDistributionTailWeight = Double.NaN;
|
||||
|
||||
/**
|
||||
* Simple constructor.
|
||||
* @param numberOfElements number of elements
|
||||
* @param exponent exponent parameter of the distribution
|
||||
*/
|
||||
ZipfRejectionSampler(final int numberOfElements, final double exponent) {
|
||||
this.numberOfElements = numberOfElements;
|
||||
this.exponent = exponent;
|
||||
}
|
||||
|
||||
/** Generate a random value sampled from this distribution.
|
||||
* @param random random generator to use
|
||||
* @return random value sampled from this distribution
|
||||
*/
|
||||
int sample(final RandomGenerator random) {
|
||||
if (Double.isNaN(instrumentalDistributionTailWeight)) {
|
||||
instrumentalDistributionTailWeight = integratePowerFunction(-exponent, 1.5, numberOfElements+0.5);
|
||||
@ -360,7 +369,7 @@ public class ZipfDistribution extends AbstractIntegerDistribution {
|
||||
* A Taylor series expansion is used, if x is close to 0.
|
||||
*
|
||||
* @param q a value in the range [0,1]
|
||||
* @param
|
||||
* @param x free parameter
|
||||
* @return log((1-q)+q*exp(x))/x
|
||||
*/
|
||||
static double helper1(final double q, final double x) {
|
||||
@ -377,6 +386,7 @@ public class ZipfDistribution extends AbstractIntegerDistribution {
|
||||
* <p>
|
||||
* A Taylor series expansion is used, if x is close to 0.
|
||||
*
|
||||
* @param x free parameter
|
||||
* @return (exp(x)-1)/x if x is non-zero, 1 if x=0
|
||||
*/
|
||||
static double helper2(final double x) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user