Skip to content

Commit 59e231f

Browse files
committed
Merge branch 'dev' of https://github.com/schmouk/PyRandLib into dev
2 parents 41399b0 + 29b230d commit 59e231f

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

README.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ Latest version of **PyRandLib** is version **2.0**, released by March 2025. It p
4141

4242
### Why not Mersenne twister?
4343

44-
The Mersenne twister PRNG proposed by Matsumoto and Nishimura - see [5] - is the most widely used one. The Random class of module random in Python
45-
implements this PRNG. It is also implemented in C++ and Java standard
46-
libraries for instance.
44+
The Mersenne twister PRNG proposed by Matsumoto and Nishimura - see [5] - is the most widely used one. The Random class of module random in Python implements this PRNG. It is also implemented in C++ and Java standard libraries for instance.
4745

4846
It offers a very good period (2^19937, i.e. about 4.3e6001). Unfortunately, this PRNG is a little bit long to compute (up to 3 times than LCGs, 60% more than LFibs and a little bit less than MRGs, see below at section 'Architecture overview'). Moreover, it fails four of the hardest TestU01 tests. You can still use it as your preferred PRNG but **PyRandLib** implements many other PRNGs that are either far faster or far better in terms of generated pseudo-randomness than the Mersenne twister PRNG.
4947

@@ -596,28 +594,28 @@ Since the base class **BaseRandom** inherits from the built-in class `random.Ran
596594
**betavariate**(self, alpha, beta)
597595
Beta distribution.
598596

599-
Conditions on the parameters are alpha > 0 and beta > 0.
597+
Conditions on the parameters are `alpha > 0` and `beta > 0`.
600598
Returned values range between 0 and 1.
601599

602600

603601
**binomialvariate**(self, n=1, p=0.5)
604-
Binomial distribution. Return the number of successes for n independent trials with the probability of success in each trial being p:
602+
Binomial distribution. Return the number of successes for `n` independent trials with the probability of success in each trial being `p`:
605603

606604
Mathematically equivalent to:
607605

608606
sum(random() < p for i in range(n))
609607

610-
The number of trials n should be a non-negative integer. The probability of success p should be between 0.0 <= p <= 1.0. The result is an integer in the range 0 <= X <= n. This built-in, method has been added since Python 3.12. **PyRandLIb** implements it also for all former versions of Python: -3.6, -3.9, -3.10, and -3.11.
608+
The number of trials `n` should be a non-negative integer. The probability of success `p` should be between `0.0 <= p <= 1.0`. The result is an integer in the range `0 <= X <= n`. This built-in method has been added since Python 3.12. **PyRandLIb** implements it also for all former versions of Python: -3.6, -3.9, -3.10, and -3.11.
611609

612610

613611
**choice**(self, seq)
614-
Chooses a random element from a non-empty sequence. 'seq' has to be non empty.
612+
Chooses a random element from a non-empty sequence. `seq` has to be non empty.
615613

616614

617615
**choices**(population, weights=None, *, cum_weights=None, k=1)
618-
Returns a *k* sized list of elements chosen from the population, with replacement. If the population is empty, raises IndexError.
616+
Returns a `k` sized list of elements chosen from the population, with replacement. If the population is empty, raises `IndexError`.
619617

620-
If a *weights* sequence is specified, selections are made according to the relative weights. Alternatively, if a *cum_weights* sequence is given, the selections are made according to the cumulative weights (perhaps computed using `itertools.accumulate()`).
618+
If a `weights` sequence is specified, selections are made according to the relative weights. Alternatively, if a `cum_weights` sequence is given, the selections are made according to the cumulative weights (perhaps computed using `itertools.accumulate()`).
621619
For example, the relative weights `[10, 5, 30, 5]` are equivalent to the cumulative weights `[10, 15, 45, 50]`.
622620
Internally, the relative weights are converted to cumulative weights before making selections, so supplying the cumulative weights saves work.
623621

@@ -633,7 +631,7 @@ Exponential distribution.
633631

634632
`lambd` is 1.0 divided by the desired mean. It should be nonzero. (The parameter should be called "lambda", but this is a reserved word in Python).
635633
Returned values range from 0 to positive infinity if `lambd` is positive, and from negative infinity to 0 if `lambd` is negative.
636-
Since Python 3.12, the parameter `lambd` gets a default value in this built-in method. **PyRandLib** defines then this method for all former versions of Pyhton : -3.6, -3.9, -3.10 and -3.11.
634+
Since Python 3.12, the parameter `lambd` gets a default value in this built-in method. **PyRandLib** defines then this method for all former versions of Python : -3.6, -3.9, -3.10 and -3.11.
637635

638636

639637
**gammavariate**(self, alpha, beta)
@@ -645,8 +643,8 @@ Conditions on the parameters are `alpha` > 0 and `beta` > 0.
645643
**gauss**(self, mu, sigma)
646644
Gaussian distribution.
647645

648-
mu is the mean, and sigma is the standard deviation.
649-
This is slightly faster than the normalvariate() function.
646+
`mu` is the mean, and `sigma` is the standard deviation.
647+
This is slightly faster than the `normalvariate()` function.
650648

651649
Not thread-safe without a lock around calls.
652650

@@ -677,7 +675,7 @@ Pareto distribution. `alpha` is the shape parameter.
677675

678676

679677
**randint**(self, a, b)
680-
Returns a random integer in range [a, b], including both end points.
678+
Returns a random integer in range `[a, b]`, including both end points.
681679

682680

683681
**randrange**(self, stop)
@@ -712,9 +710,9 @@ Restores internal state from object returned by `getstate()`.
712710

713711

714712
**shuffle**(self, x, random=None)
715-
Shuffle the sequence x in place. Returns None.
713+
Shuffle the sequence `x` in place. Returns None.
716714

717-
The optional argument `random` is a 0-argument function returning a random float in [0.0, 1.0); by default, this is the function random().
715+
The optional argument `random` is a 0-argument function returning a random float in `[0.0, 1.0)`; by default, this is the function random().
718716

719717
To shuffle an immutable sequence and return a new shuffled list, use `sample(x, k=len(x))` instead.
720718

@@ -730,7 +728,7 @@ see [http://en.wikipedia.org/wiki/Triangular_distribution](http://en.wikipedia.o
730728

731729

732730
**uniform**(self, a, b)
733-
Gets a random number in the range [`a`, `b`) or [`a`, `b`] depending on rounding.
731+
Gets a random number in the range `[a, b)` or `[a, b]` depending on rounding.
734732

735733

736734
**vonmisesvariate**(self, mu, kappa)

0 commit comments

Comments
 (0)