MATH-1158. Method "createSampler" overridden in "ParetoDistribution".
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/228b49fe Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/228b49fe Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/228b49fe Branch: refs/heads/feature-MATH-1158 Commit: 228b49fe2afea3376c4f30f80bdeb70d083a9206 Parents: 82f4ce5 Author: Gilles <er...@apache.org> Authored: Sat Mar 12 02:38:42 2016 +0100 Committer: Gilles <er...@apache.org> Committed: Sat Mar 12 02:38:42 2016 +0100 ---------------------------------------------------------------------- .../math4/distribution/ParetoDistribution.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-math/blob/228b49fe/src/main/java/org/apache/commons/math4/distribution/ParetoDistribution.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/distribution/ParetoDistribution.java b/src/main/java/org/apache/commons/math4/distribution/ParetoDistribution.java index 3f3fbb2..bd074fa 100644 --- a/src/main/java/org/apache/commons/math4/distribution/ParetoDistribution.java +++ b/src/main/java/org/apache/commons/math4/distribution/ParetoDistribution.java @@ -21,6 +21,7 @@ import org.apache.commons.math4.exception.NotStrictlyPositiveException; import org.apache.commons.math4.exception.util.LocalizedFormats; import org.apache.commons.math4.random.RandomGenerator; import org.apache.commons.math4.random.Well19937c; +import org.apache.commons.math4.rng.UniformRandomProvider; import org.apache.commons.math4.util.FastMath; /** @@ -117,6 +118,7 @@ public class ParetoDistribution extends AbstractRealDistribution { * @param shape Shape parameter of this distribution. * @throws NotStrictlyPositiveException if {@code scale <= 0} or {@code shape <= 0}. */ + @Deprecated public ParetoDistribution(RandomGenerator rng, double scale, double shape) throws NotStrictlyPositiveException { this(rng, scale, shape, DEFAULT_INVERSE_ABSOLUTE_ACCURACY); @@ -131,6 +133,7 @@ public class ParetoDistribution extends AbstractRealDistribution { * @param inverseCumAccuracy Inverse cumulative probability accuracy. * @throws NotStrictlyPositiveException if {@code scale <= 0} or {@code shape <= 0}. */ + @Deprecated public ParetoDistribution(RandomGenerator rng, double scale, double shape, @@ -295,8 +298,22 @@ public class ParetoDistribution extends AbstractRealDistribution { /** {@inheritDoc} */ @Override + @Deprecated public double sample() { final double n = random.nextDouble(); return scale / FastMath.pow(n, 1 / shape); } + + /** {@inheritDoc} */ + @Override + public RealDistribution.Sampler createSampler(final UniformRandomProvider rng) { + return new RealDistribution.Sampler() { + /** {@inheritDoc} */ + @Override + public double sample() { + final double n = rng.nextDouble(); + return scale / FastMath.pow(n, 1 / shape); + } + }; + } }