Class InverseTransformParetoSampler
- java.lang.Object
-
- org.apache.commons.rng.sampling.distribution.SamplerBase
-
- org.apache.commons.rng.sampling.distribution.InverseTransformParetoSampler
-
- All Implemented Interfaces:
ContinuousSampler
,SharedStateContinuousSampler
,SharedStateSampler<SharedStateContinuousSampler>
public class InverseTransformParetoSampler extends SamplerBase implements SharedStateContinuousSampler
Sampling from a Pareto distribution.Sampling uses
UniformRandomProvider.nextLong()
.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.LongToDoubleFunction
nextDouble
Method to generate the (1 - p) value.private double
oneOverShape
1 / Shape.private UniformRandomProvider
rng
Underlying source of randomness.private double
scale
Scale.
-
Constructor Summary
Constructors Modifier Constructor Description private
InverseTransformParetoSampler(double scale, double shape, UniformRandomProvider rng)
InverseTransformParetoSampler(UniformRandomProvider rng, double scale, double shape)
Create an instance.private
InverseTransformParetoSampler(UniformRandomProvider rng, InverseTransformParetoSampler source)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SharedStateContinuousSampler
of(UniformRandomProvider rng, double scale, double shape)
Creates a new Pareto distribution sampler.double
sample()
Creates adouble
sample.java.lang.String
toString()
SharedStateContinuousSampler
withUniformRandomProvider(UniformRandomProvider rng)
Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.-
Methods inherited from class org.apache.commons.rng.sampling.distribution.SamplerBase
nextDouble, nextInt, nextInt, nextLong
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.commons.rng.sampling.distribution.ContinuousSampler
samples, samples
-
-
-
-
Field Detail
-
scale
private final double scale
Scale.
-
oneOverShape
private final double oneOverShape
1 / Shape.
-
rng
private final UniformRandomProvider rng
Underlying source of randomness.
-
nextDouble
private final java.util.function.LongToDoubleFunction nextDouble
Method to generate the (1 - p) value.
-
-
Constructor Detail
-
InverseTransformParetoSampler
public InverseTransformParetoSampler(UniformRandomProvider rng, double scale, double shape)
Create an instance.- Parameters:
rng
- Generator of uniformly distributed random numbers.scale
- Scale of the distribution.shape
- Shape of the distribution.- Throws:
java.lang.IllegalArgumentException
- ifscale <= 0
orshape <= 0
-
InverseTransformParetoSampler
private InverseTransformParetoSampler(double scale, double shape, UniformRandomProvider rng)
- Parameters:
scale
- Scale of the distribution.shape
- Shape of the distribution.rng
- Generator of uniformly distributed random numbers.
-
InverseTransformParetoSampler
private InverseTransformParetoSampler(UniformRandomProvider rng, InverseTransformParetoSampler source)
- Parameters:
rng
- Generator of uniformly distributed random numbers.source
- Source to copy.
-
-
Method Detail
-
sample
public double sample()
Creates adouble
sample.- Specified by:
sample
in interfaceContinuousSampler
- Returns:
- a sample.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classSamplerBase
-
withUniformRandomProvider
public SharedStateContinuousSampler withUniformRandomProvider(UniformRandomProvider rng)
Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.- Specified by:
withUniformRandomProvider
in interfaceSharedStateSampler<SharedStateContinuousSampler>
- Parameters:
rng
- Generator of uniformly distributed random numbers.- Returns:
- the sampler
- Since:
- 1.3
-
of
public static SharedStateContinuousSampler of(UniformRandomProvider rng, double scale, double shape)
Creates a new Pareto distribution sampler.- Parameters:
rng
- Generator of uniformly distributed random numbers.scale
- Scale of the distribution.shape
- Shape of the distribution.- Returns:
- the sampler
- Throws:
java.lang.IllegalArgumentException
- ifscale <= 0
orshape <= 0
- Since:
- 1.3
-
-