In LogNormalDistribution and LogNormalDistributionTest
- "mean" (of the underlying normal distribution) is now called "scale" - "standard deviation" (of the underlying normal distribution) is now called "shape" - in the javadoc, removed html links that point to internal anchors. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1232755 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e2c0e16bff
commit
47a87ce229
|
@ -27,7 +27,7 @@ import org.apache.commons.math.util.FastMath;
|
||||||
* Implementation of the log-normal (gaussian) distribution.
|
* Implementation of the log-normal (gaussian) distribution.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* <a id="parameters"><strong>Parameters:</strong></a>
|
* <strong>Parameters:</strong>
|
||||||
* {@code X} is log-normally distributed if its natural logarithm {@code log(X)}
|
* {@code X} is log-normally distributed if its natural logarithm {@code log(X)}
|
||||||
* is normally distributed. The probability distribution function of {@code X}
|
* is normally distributed. The probability distribution function of {@code X}
|
||||||
* is given by (for {@code x > 0})
|
* is given by (for {@code x > 0})
|
||||||
|
@ -64,19 +64,17 @@ public class LogNormalDistribution extends AbstractRealDistribution {
|
||||||
/** √(2) */
|
/** √(2) */
|
||||||
private static final double SQRT2 = FastMath.sqrt(2.0);
|
private static final double SQRT2 = FastMath.sqrt(2.0);
|
||||||
|
|
||||||
/** The <a href="#parameters">scale</a> parameter of this distribution. */
|
/** The scale parameter of this distribution. */
|
||||||
private final double scale;
|
private final double scale;
|
||||||
|
|
||||||
/** The <a href="#parameters">shape</a> parameter of this distribution. */
|
/** The shape parameter of this distribution. */
|
||||||
private final double shape;
|
private final double shape;
|
||||||
|
|
||||||
/** Inverse cumulative probability accuracy. */
|
/** Inverse cumulative probability accuracy. */
|
||||||
private final double solverAbsoluteAccuracy;
|
private final double solverAbsoluteAccuracy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a log-normal distribution using the specified
|
* Create a log-normal distribution using the specified scale and shape.
|
||||||
* <a href="#parameters">scale</a> and
|
|
||||||
* <a href="#parameters">shape</a>.
|
|
||||||
*
|
*
|
||||||
* @param scale the scale parameter of this distribution
|
* @param scale the scale parameter of this distribution
|
||||||
* @param shape the shape parameter of this distribution
|
* @param shape the shape parameter of this distribution
|
||||||
|
@ -88,8 +86,7 @@ public class LogNormalDistribution extends AbstractRealDistribution {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a log-normal distribution using the specified
|
* Create a log-normal distribution using the specified scale, shape and
|
||||||
* <a href="#parameters">scale</a>, <a href="#parameters">shape</a> and
|
|
||||||
* inverse cumulative distribution accuracy.
|
* inverse cumulative distribution accuracy.
|
||||||
*
|
*
|
||||||
* @param scale the scale parameter of this distribution
|
* @param scale the scale parameter of this distribution
|
||||||
|
@ -100,7 +97,7 @@ public class LogNormalDistribution extends AbstractRealDistribution {
|
||||||
public LogNormalDistribution(double scale, double shape,
|
public LogNormalDistribution(double scale, double shape,
|
||||||
double inverseCumAccuracy) throws NotStrictlyPositiveException {
|
double inverseCumAccuracy) throws NotStrictlyPositiveException {
|
||||||
if (shape <= 0) {
|
if (shape <= 0) {
|
||||||
throw new NotStrictlyPositiveException(LocalizedFormats.STANDARD_DEVIATION, shape);
|
throw new NotStrictlyPositiveException(LocalizedFormats.SHAPE, shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
|
@ -120,7 +117,7 @@ public class LogNormalDistribution extends AbstractRealDistribution {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the <a href="#parameters">scale</a> parameter of this distribution.
|
* Returns the scale parameter of this distribution.
|
||||||
*
|
*
|
||||||
* @return the scale parameter
|
* @return the scale parameter
|
||||||
*/
|
*/
|
||||||
|
@ -129,8 +126,7 @@ public class LogNormalDistribution extends AbstractRealDistribution {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the <a href="#parameters">shape</a> parameter of this
|
* Returns the shape parameter of this distribution.
|
||||||
* distribution.
|
|
||||||
*
|
*
|
||||||
* @return the shape parameter
|
* @return the shape parameter
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -164,13 +164,13 @@ public class LogNormalDistributionTest extends RealDistributionAbstractTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetMean() {
|
public void testGetScale() {
|
||||||
LogNormalDistribution distribution = (LogNormalDistribution)getDistribution();
|
LogNormalDistribution distribution = (LogNormalDistribution)getDistribution();
|
||||||
Assert.assertEquals(2.1, distribution.getScale(), 0);
|
Assert.assertEquals(2.1, distribution.getScale(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetStandardDeviation() {
|
public void testGetShape() {
|
||||||
LogNormalDistribution distribution = (LogNormalDistribution)getDistribution();
|
LogNormalDistribution distribution = (LogNormalDistribution)getDistribution();
|
||||||
Assert.assertEquals(1.4, distribution.getShape(), 0);
|
Assert.assertEquals(1.4, distribution.getShape(), 0);
|
||||||
}
|
}
|
||||||
|
@ -193,8 +193,9 @@ public class LogNormalDistributionTest extends RealDistributionAbstractTest {
|
||||||
0.1836267118});
|
0.1836267118});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkDensity(double mean, double sd, double[] x, double[] expected) {
|
private void checkDensity(double scale, double shape, double[] x,
|
||||||
LogNormalDistribution d = new LogNormalDistribution(mean, sd);
|
double[] expected) {
|
||||||
|
LogNormalDistribution d = new LogNormalDistribution(scale, shape);
|
||||||
for (int i = 0; i < x.length; i++) {
|
for (int i = 0; i < x.length; i++) {
|
||||||
Assert.assertEquals(expected[i], d.density(x[i]), 1e-9);
|
Assert.assertEquals(expected[i], d.density(x[i]), 1e-9);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue