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
FieldsModifier and TypeFieldDescriptionprivate final LongToDoubleFunctionMethod to generate the (1 - p) value.private final double1 / Shape.private final UniformRandomProviderUnderlying source of randomness.private final doubleScale. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateInverseTransformParetoSampler(double scale, double shape, UniformRandomProvider rng) InverseTransformParetoSampler(UniformRandomProvider rng, double scale, double shape) Create an instance.private -
Method Summary
Modifier and TypeMethodDescriptionstatic SharedStateContinuousSamplerof(UniformRandomProvider rng, double scale, double shape) Creates a new Pareto distribution sampler.doublesample()Creates adoublesample.toString()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 SamplerBase
nextDouble, nextInt, nextInt, nextLongMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ContinuousSampler
samples, samples
-
Field Details
-
scale
private final double scaleScale. -
oneOverShape
private final double oneOverShape1 / Shape. -
rng
Underlying source of randomness. -
nextDouble
Method to generate the (1 - p) value.
-
-
Constructor Details
-
InverseTransformParetoSampler
Create an instance.- Parameters:
rng- Generator of uniformly distributed random numbers.scale- Scale of the distribution.shape- Shape of the distribution.- Throws:
IllegalArgumentException- ifscale <= 0orshape <= 0
-
InverseTransformParetoSampler
- 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 Details
-
sample
public double sample()Creates adoublesample.- Specified by:
samplein interfaceContinuousSampler- Returns:
- a sample.
-
toString
- Overrides:
toStringin classSamplerBase
-
withUniformRandomProvider
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:
withUniformRandomProviderin 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:
IllegalArgumentException- ifscale <= 0orshape <= 0- Since:
- 1.3
-