Package jline.gen
Class MatlabRandom
java.lang.Object
jline.gen.MatlabRandom
MATLAB-faithful random draws for the model generators.
One process-wide MT19937 stream plays the role of MATLAB's global generator: after
rng(long) it yields the stream MATLAB yields after rng(seed), so a generator
seeded alike builds the same model in MATLAB, Python and the JAR. rand is
numpy's random_sample, randi([lo,hi]) is lo-1+ceil((hi-lo+1)*rand)
(a degenerate range still consumes a draw) and randperm(n) is the stable sort order
of rand(1,n). Checked against MATLAB R2026a on 2026-10-13.
-
Method Summary
Modifier and TypeMethodDescriptionstatic doublerand()One MATLABranddraw.static double[]randfixedsum(int n, double s, double a, double b) One column of Roger Stafford'srandfixedsum(n,1,s,a,b), transcribed frommatlab/lib/thirdparty/randfixedsum.mwith its draw order:rand(n-1,1)twice, thenrand(n,1)for the permutation.static intrandi(int lo, int hi) MATLABrandi([lo, hi]).static int[]randperm(int n) MATLABrandperm(n), returned 0-based.static voidrng(long seed) Reseeds the shared stream, as MATLABrng(seed).
-
Method Details
-
rng
public static void rng(long seed) Reseeds the shared stream, as MATLABrng(seed). -
rand
public static double rand()One MATLABranddraw. -
randi
public static int randi(int lo, int hi) MATLABrandi([lo, hi]). -
randperm
public static int[] randperm(int n) MATLABrandperm(n), returned 0-based. -
randfixedsum
public static double[] randfixedsum(int n, double s, double a, double b) One column of Roger Stafford'srandfixedsum(n,1,s,a,b), transcribed frommatlab/lib/thirdparty/randfixedsum.mwith its draw order:rand(n-1,1)twice, thenrand(n,1)for the permutation.
-