Package jline.opt.solver.de
Class NumpyRandomState
java.lang.Object
jline.opt.solver.de.NumpyRandomState
Bit-exact port of the subset of
numpy.random.RandomState consumed by
scipy's differential_evolution. Backed by MT19937.
Implements random_sample, uniform, the default-dtype
randint (32-bit masked rejection), and shuffle/
permutation (Fisher-Yates driven by random_interval), each
reproducing numpy's exact draw sequence and word consumption. This lets the
differential-evolution optimizer follow the identical trajectory to the
native-Python line-opt for a given integer seed.
Java 8 compatible.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint[]permutation(int n) numpy permutation(range(n)): shuffled copy of [0, 1, ..., n-1].longrandint(long high) Convenience: randint(0, high).longrandint(long low, long high) numpy randint(low, high) with the default integer dtype: a uniform integer in [low, high) via 32-bit masked rejection (one word per rejection iteration), matching numpy's word consumption exactly.longrandomInterval(long max) numpy random_interval(max): a uniform integer in [0, max] inclusive via 32-bit masked rejection.doublenumpy random_sample(): a 53-bit double in [0, 1) from two 32-bit words.double[]randomSample(int n) numpy random_sample(size): C-order fill of length n.voidshuffle(int[] arr) numpy shuffle: in-place Fisher-Yates using random_interval.doubleuniform(double low, double high) numpy uniform(low, high): scalar draw.double[]uniform(double low, double high, int n) numpy uniform(low, high, size=n): C-order fill of length n.double[]uniform(int n) numpy uniform(size=n) == uniform(0, 1, n).
-
Constructor Details
-
NumpyRandomState
public NumpyRandomState(long seed) -
NumpyRandomState
-
-
Method Details
-
getGenerator
-
randomSample
public double randomSample()numpy random_sample(): a 53-bit double in [0, 1) from two 32-bit words. -
randomSample
public double[] randomSample(int n) numpy random_sample(size): C-order fill of length n. -
uniform
public double uniform(double low, double high) numpy uniform(low, high): scalar draw. -
uniform
public double[] uniform(double low, double high, int n) numpy uniform(low, high, size=n): C-order fill of length n. -
uniform
public double[] uniform(int n) numpy uniform(size=n) == uniform(0, 1, n). -
randint
public long randint(long low, long high) numpy randint(low, high) with the default integer dtype: a uniform integer in [low, high) via 32-bit masked rejection (one word per rejection iteration), matching numpy's word consumption exactly. -
randint
public long randint(long high) Convenience: randint(0, high). -
randomInterval
public long randomInterval(long max) numpy random_interval(max): a uniform integer in [0, max] inclusive via 32-bit masked rejection. Used by shuffle/permutation. -
shuffle
public void shuffle(int[] arr) numpy shuffle: in-place Fisher-Yates using random_interval. -
permutation
public int[] permutation(int n) numpy permutation(range(n)): shuffled copy of [0, 1, ..., n-1].
-