Commit Graph

2864 Commits

Author SHA1 Message Date
Vinzent Steinberg 18bea4ca94 Add missing impls to *InverseGaussian errors 2021-05-13 14:52:23 -03:00
Vinzent Steinberg 2c32fe0b04 Implement Clone and Debug for {Normal,}InverseGaussian 2021-05-13 14:45:30 -03:00
Vinzent Steinberg 3f210e75f7 Implement Clone and Debug for Alphanumeric 2021-05-13 14:41:46 -03:00
Vinzent Steinberg 13738d337d Merge pull request #1107 from Lucretiel/slice-distribution
Initial implementation of Slice distribution
2021-05-12 14:51:36 -03:00
Vinzent Steinberg d86db46638 Merge branch 'master' into slice-distribution 2021-05-12 14:42:50 -03:00
Vinzent Steinberg 701c2c77c8 Slice::new: Fix return type documentation 2021-05-12 14:41:24 -03:00
Vinzent Steinberg 6bfc5a88e6 Slice: Derive Clone and Copy 2021-05-12 14:38:22 -03:00
Vinzent Steinberg 13949eeccd Update changelog 2021-05-12 13:59:41 -03:00
Vinzent Steinberg 4d4ae25541 Add missing licence header 2021-05-12 13:55:15 -03:00
Vinzent Steinberg 6d236fd8ef Merge pull request #1121 from vks/distr-test
Compare sampled normal distribution to PDF
2021-05-12 13:28:31 -03:00
Vinzent Steinberg 66da6e633a Simplify loop 2021-05-09 14:55:35 -03:00
Vinzent Steinberg 76a7305f22 Define constant for histogram size 2021-05-09 14:45:09 -03:00
Vinzent Steinberg 8dac1dcb82 Fix Rust 1.36 compatibility 2021-05-08 21:46:02 -03:00
Vinzent Steinberg ab6f3dd5cd Add missing copyright headers 2021-05-08 21:39:31 -03:00
Vinzent Steinberg 1b8eaf23ea rand: Fix clippy warnings 2021-05-08 21:37:15 -03:00
Vinzent Steinberg aee00443d4 rand_hc: Fix clippy warnings 2021-05-08 21:36:12 -03:00
Vinzent Steinberg 67f491a7a5 rand_core: Fix clippy warnings 2021-05-08 21:35:09 -03:00
Vinzent Steinberg 0cde3bf20c rand_distr: Fix clippy warnings 2021-05-08 21:05:49 -03:00
Vinzent Steinberg 70efd2e180 Another fix for old Rust 2021-05-08 20:33:46 -03:00
Vinzent Steinberg da94e87819 More fixes for old Rust versions 2021-05-08 20:21:26 -03:00
Vinzent Steinberg eeeb9ea290 Merge pull request #1120 from mgeisler/patch-1
Ensure `Array64` is `repr(transparent)`
2021-05-08 22:13:50 +02:00
Diggory Hardy f0e01ee0a7 Merge pull request #1122 from vks/pcg-stream-corr
Document dependencies between PCG streams
2021-05-08 08:31:37 +01:00
Vinzent Steinberg e8329a2d01 Fix tests for old Rust versions 2021-05-07 18:46:27 -03:00
Vinzent Steinberg 9121d39732 Document dependencies between PCG streams
Fixes #907.
2021-05-07 18:33:06 -03:00
Vinzent Steinberg c8561f4d94 rand_distr: Test normal distribution
`Normal` is sampled many times into a histogram, which is then compared
to the expected probability density function. To make debugging easier,
sparklines of the expected distribution, the histogram, and their
difference are printed.

Currently, the test fails if the difference is significantly larger than
the expected error of the histogram bin. However, the error estimate
does not take the error in the normalization due to the finite width of
the histogram into account. This should not be a problem, as long as the
distribution is almost zero outside the range covered by the histogram.

In principle, this approach can be generalized to other distributions.
2021-05-07 17:47:40 -03:00
Vinzent Steinberg 0eb245415f Implement sparklines
Those will only be used for testing distributions.
2021-05-07 17:44:47 -03:00
Vinzent Steinberg fd50cd418a Update dependency 2021-05-07 17:44:08 -03:00
Martin Geisler 0f4931967d Ensure Array64 is repr(transparent)
Let me start by saying that I'm far from an expert when it comes to unsafe code in Rust. However, if I read [RFC 1758](https://github.com/rust-lang/rfcs/blob/master/text/1758-repr-transparent.md) correctly, it it seems that `Array64` should be marked `repr(transparent)`. This is because I believe it is considered an implementation detail that single-element tuple structs currently have the same representation as its single field:

> As a matter of optimisation, eligible #[repr(Rust)] structs behave as if they were #[repr(transparent)] but as an implementation detail that can't be relied upon by users.

With the transparent representation, the `generate` method can safely cast the `Array64<u32>` argument:

```rust
                // Fill slice of words by writing to equivalent slice of bytes, then fixing endianness.
                self.state.refill4($rounds, unsafe {
                    &mut *(&mut *r as *mut Array64<u32> as *mut [u8; 256])
                });
```
2021-05-07 13:12:09 +02:00
Diggory Hardy 30d2d98df5 Merge pull request #1118 from Minoru/feature/warn-against-pathological-rngs
RngCore: explain what a pathological RNG will break
2021-04-30 13:44:18 +01:00
Alexander Batischev 25c1c49541 RngCore: explain what a pathological RNG will break
Cf. https://github.com/rust-random/rngs/pull/25#discussion_r622770225.
2021-04-30 14:41:07 +03:00
Vinzent Steinberg 9918cc100c Merge pull request #1119 from Minoru/bugfix/warning-panic-msg-not-string-literal
Bump "average" crate to 0.12
2021-04-29 23:58:45 +02:00
Vinzent Steinberg cd48ceb988 Merge pull request #1117 from vks/fix-miri
Fix Miri tests
2021-04-29 23:45:38 +02:00
Alexander Batischev a4e1d1c2d7 Bump "average" crate to 0.12
This fixes the following warnings (from rustc 1.51.1):

warning: panic message is not a string literal
  --> rand_distr/tests/value_stability.rs:29:9
   |
29 |         assert_almost_eq!(self, rhs, 1e-6);
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: panic message is not a string literal
  --> rand_distr/tests/value_stability.rs:34:9
   |
34 |         assert_almost_eq!(self, rhs, 1e-14);
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this is no longer accepted in Rust 2021
   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: panic message is not a string literal
   --> rand_distr/tests/value_stability.rs:380:9
    |
380 |         assert_almost_eq!(a, b, 1e-5);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this is no longer accepted in Rust 2021
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2021-04-29 22:45:15 +03:00
Vinzent Steinberg c1e0a87044 Fix Miri tests
Because Miri now runs the doctests as well, we have to make sure it does
not run them for `no_std` targets, like we do for our normal tests.
2021-04-25 15:57:11 -03:00
Vinzent Steinberg e9ac35f5f5 Merge pull request #1115 from rust-random/rand_distr-changelog
rand_distr: Update changelog
2021-04-25 18:20:08 +02:00
Vinzent Steinberg 9b1f7717cd Merge pull request #1111 from markwkm/advance
Add an advance function to PCG generators
2021-04-23 19:46:46 +02:00
Mark Wong 57cd95999d Expand advancing tests to use multiple seeds 2021-04-22 16:32:08 -07:00
Vinzent Steinberg 2c6223bec6 rand_distr: Update changelog 2021-04-22 02:30:52 +02:00
Mark Wong c775705b88 Touch up changes around advancing feature
* Add additional comments on how to use the advance() function
* Use clone() for clarity instead of reusing a seed
* Compare the generator as a whole as opposed the next value in unit
  tests
2021-04-20 20:50:10 -07:00
Mark Wong 53b54b247e Fix Lcg64Xsh32 advancing test to use 32 bit generation functions 2021-04-19 14:12:23 -07:00
Mark Wong f7960e9fb2 Revert "Delta needs to be doubled when advancing Lcg64Xsh32"
This reverts commit 624d24e8ae.
2021-04-19 14:00:18 -07:00
Vinzent Steinberg 285bc66b7e Merge pull request #1114 from jturner314/normal-distr-accessors
Add mean and std_dev accessors to Normal
2021-04-17 02:39:38 +02:00
Mark Wong 624d24e8ae Delta needs to be doubled when advancing Lcg64Xsh32 2021-04-16 13:52:56 -07:00
Diggory Hardy 247d287515 Merge pull request #1108 from dhardy/work
Uniform float asserts and tests
2021-04-15 11:55:26 +01:00
Mark Wong 9017732011 Add tests for advancing PCG generators
A simple test to check the values after 20 steps.
2021-04-10 17:35:00 -07:00
Jim Turner 4bb723ee2f Add mean and std_dev accessors to Normal 2021-04-08 19:28:47 -04:00
Diggory Hardy 2582115290 Merge pull request #1100 from rust-random/rand_distr-features-doc
Correctly document `rand_distr` features and forward "std" feature to `num-traits`
2021-04-08 09:17:10 +01:00
Vinzent Steinberg 35be169068 Merge pull request #1113 from TheIronBorn/patch-12
fix xoshiro256++ documentation
2021-04-08 01:13:31 +02:00
TheIronBorn a886beb64e fix xoshiro256++ documentation 2021-04-06 08:07:16 +00:00
Diggory Hardy 19611ba898 Merge pull request #1112 from ndebuhr/distr-docs
Update and tweak the rand_distr README
2021-04-05 07:45:47 +01:00