3278 Commits

Author SHA1 Message Date
Vinzent Steinberg
d9a89c8f13 Add example for initializing a PCG RNG (#1347) 2023-10-30 21:24:34 +01:00
OldEnglishSheepdog
d0499f0a26
Correcting method name in comment (#1350)
Co-authored-by: Detlef <none@none.org>
2023-10-30 09:39:38 +00:00
Joshua Liebow-Feeser
5216f9a7fc Remove some unsafe code 2023-10-29 16:07:50 -04:00
Nathan West
9a02c819cc
Simplify macro implementation for tuples (#1340) 2023-10-11 08:56:15 +01:00
bjorn3
e42c385872
MSRV=1.60, use more permissive cfg on test
* Use cfg(panic = unwind) instead of a check for wasm32 to see if unwinding is supported

This allows the test to run on a future wasm target with exception support as
well as running the test suite with panic=abort on non-wasm targets.

* Bump MSRV to 1.60
2023-10-11 08:54:54 +01:00
Artyom Pavlov
0c28ebad0b
Improve doc of slice and iterator "choose" methods (#1343) 2023-10-10 13:43:22 +03:00
Diggory Hardy
e609fa98fc Replace MIPS with PPC32 2023-10-10 10:17:55 +01:00
Diggory Hardy
7d510d7397 Improve doc of slice and iterator "choose" methods 2023-10-10 09:28:49 +01:00
TheIronBorn
f3dd0b885c
fix partial_shuffle documentation (#1335) 2023-08-24 11:07:56 +01:00
Vinzent Steinberg
5b990046d5
Merge pull request #1332 from elichai/nz
Implement Standard support for signed NonZero* types
2023-08-20 22:56:57 +02:00
Vinzent Steinberg
02b6eb0f18
Merge pull request #1331 from vks/try-from-panic
Add tests for `Uniform::try_from` with invalid ranges
2023-08-20 22:52:39 +02:00
Elichai Turkel
dcefa4aa68
Implement Standard support for signed NonZero* types 2023-08-13 18:06:24 +03:00
Vinzent Steinberg
1b9d897cb7 Add tests for Uniform::try_from with invalid ranges 2023-08-09 20:41:28 +02:00
Guillaume Gomez
176e73647a
Add --generate-link-to-definition option when building on docs.rs (#1327)
* Add `--generate-link-to-definition` option when building on docs.rs

* Fix documentation issues
2023-07-29 08:12:57 +01:00
aobatact
ee80b41619
Add DistString impl to Uniform and Slice (#1315)
* Add impl for `DistString` to `Uniform` and `Slice`

* Fix `DistString` impl.
2023-07-14 09:39:27 +01:00
Vinzent Steinberg
c354b6a9c3
Merge pull request #1325 from Unlikus/fix_infinite_loop_binv
Fix infinite loop in Binomial distribution
2023-07-14 08:18:27 +02:00
benjamin
a4739d8bd4 Add test for infinite loop 2023-07-05 08:58:12 +02:00
benjamin
c5af1f8072 Fix spaces 2023-07-05 08:56:46 +02:00
Benjamin Lieser
dc8bc097e3
Update rand_distr/src/binomial.rs
Some formatting

Co-authored-by: Vinzent Steinberg <Vinzent.Steinberg@gmail.com>
2023-07-04 23:04:40 +02:00
Benjamin Lieser
c7c65979a8 Fix infinite loop in Binomial distribution 2023-07-04 17:42:15 +02:00
Warren Weckesser
b593db692d
Replace tab character with spaces in poisson.rs. (#1320) 2023-06-20 15:50:19 +01:00
Diggory Hardy
0c4c6c02d8
impl TrustedLen is unsafe (#1318)
* impl TrustedLen is unsafe

Implementing `TrustedLen` is now unsafe.

From what I understand, quite a few people are still unhappy about the design since the `unsafe` marker in this case is a promise that `size_hint()` in a *different* impl is accurate, so this may change again.

Anyway, we need to do something to fix our builds, and the alternative is just to remove this (I haven't a clue if it is enabling any important optimisations).

* Remove TrustedLen impl for DistIter
2023-06-12 07:38:23 +01:00
LiosK
51d27a9795
ReseedingRng: fix doc comment on reseeding behavior after UNIX fork (#1317)
It reads "For ChaCha and Hc128 this is a maximum of fifteen `u32` values before
reseeding" while rand_chacha v0.2.0 or higher actually consumes 63 `u32` values
before reseeding.
2023-06-04 08:20:05 +01:00
ihc童鞋@提不起劲
a747b1dcf7
fix feature typo (#1316) 2023-06-02 15:32:25 +01:00
Vinzent Steinberg
33a872a155
Merge pull request #1305 from dhardy/gen_iter
Re-introduce Rng::gen_iter
2023-05-01 17:39:01 +02:00
Vinzent Steinberg
d4a29450b1
Merge pull request #1289 from dhardy/uniform-float
Uniform float improvements
2023-05-01 17:38:05 +02:00
Vinzent Steinberg
1464b8808f
Merge pull request #1209 from WarrenWeckesser/dirichlet-small-alpha
rand_distr: Fix dirichlet sample method for small alpha.
2023-05-01 17:36:13 +02:00
Vinzent Steinberg
026292d316
Merge branch 'master' into uniform-float 2023-05-01 16:39:12 +02:00
Michael Schubart
7fcc5ebf7c
Fix manual slice size calcuation (#1308) 2023-04-06 18:10:58 +01:00
warren
c12db0b8ee Use an array for DirichletFromGamma.samplers 2023-03-30 15:35:22 -04:00
Diggory Hardy
c6cca9cb81
StepRng: better documentation of outputs for other types (#1304) 2023-03-26 17:52:45 +01:00
warren
22256529a4 Copy-edit a comment and make it a doc comment. 2023-03-25 10:06:58 -04:00
warren
7fcb25f11e Merge branch 'master' into dirichlet-small-alpha 2023-03-25 10:00:20 -04:00
warren
7c97f9b86d Merge master and fix conflicts.
The main change is that Dirichlet now has a const trait N for
the dimension.  The other significant change is to propagate
errors that could occur when Beta:new or Gamma::new is called.
2023-03-25 09:49:08 -04:00
Diggory Hardy
22d0756b68
Uniform sampling: use Canon's method, Lemire's method (#1287)
Also:

* Add uniform distribution benchmarks
* Add "unbiased" feature flag
* Fix feature simd_support
* Uniform: impl PartialEq, Eq where possible
* CI: benches now require small_rng; build-test unbiased
2023-03-24 12:29:15 +00:00
Diggory Hardy
145c6a2b82 Re-introduce Rng::gen_iter 2023-03-23 10:38:07 +00:00
Diggory Hardy
ee1653c35f CI: benches require small_rng 2023-03-18 10:05:27 +00:00
Diggory Hardy
8d98d4531d Bench uniform_float: better grouping of plots
Also avoid using internal API of Uniform distribution.
2023-03-18 09:54:12 +00:00
Virgile Andreani
0f5af6672d
Use const generics in Dirichlet (#1292)
* Use const generics in Dirichlet

* Serialize const arrays with serde_with
2023-03-18 09:21:59 +00:00
warren
030d2ad4f4 Fix namespace qualifier for Serialize and Deserialize. 2023-02-28 20:54:28 -05:00
warren
7513e838b7 Convert Dirichlet from an enum to a struct containing an enum. 2023-02-28 20:01:42 -05:00
warren
4ecb35eaf0 Refactor:
* Create a struct for each random variate generation method:
  DirichletFromGamma and DirichletFromBeta.
* Move the initialization of the data required by the generators
  into the new() method.
* Make the main Dirichlet object an enum.
2023-02-28 16:12:12 -05:00
warren
c44ac16e40 Merge branch 'master' into dirichlet-small-alpha 2023-02-27 19:22:54 -05:00
Thomas Dupic
0f3ecedef0
Poisson distribution falls into an infinite loop for parameter λ=∞ (#1290) (#1291) 2023-02-27 08:08:13 +00:00
Alex Saveau
17c8b2625c
Don't run the random write test (#1294) 2023-02-27 08:07:03 +00:00
Diggory Hardy
7aedb36373 Uniform for floats: extra tests 2023-02-21 15:49:26 +00:00
Diggory Hardy
5e5879a591 Add direct impl of sample_single_inclusive for floats
Around 20% faster for f32, slightly less for f64.
2023-02-21 12:58:50 +00:00
Diggory Hardy
95b366ff53 Add uniform_float benchmark
Note: sample_single and sample_single_inclusive use
different code paths for sampling.
2023-02-21 12:58:18 +00:00
Artyom Pavlov
7c1e649ea1
Rework CryptoRng (#1273) 2023-02-20 10:28:23 +00:00
Oliver Tearne
f2e21db971
Poisson returns -1 for small lambda (#1284)
* Correct Knuth's method since not using do-while
2023-02-13 09:08:01 +00:00