Skip to content

Commit

Permalink
Merge branch 'master' into work
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Jul 9, 2021
2 parents 564a504 + 8a07c93 commit af751df
Show file tree
Hide file tree
Showing 25 changed files with 46 additions and 32 deletions.
10 changes: 5 additions & 5 deletions CHANGELOG.md
Expand Up @@ -8,19 +8,19 @@ A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md).

You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful.

## [Unreleased]
## [0.8.4] - 2021-06-15
### Additions
- Use const-generics to support arrays of all sizes (#1104)
- Implement `Clone` and `Copy` for `Alphanumeric` (#1126)
- Add `Distribution::map` to derive a distribution using a closure (#1129)
- Add `Slice` distribution (#1107)
- Add `DistString` trait with impls for `Standard` and `Alphanumeric` (#1133)

### Other
- Reorder asserts in `Uniform` float distributions for easier debugging of non-finite arguments
(#1094, #1108)
- Add range overflow check in `Uniform` float distributions (#1108)

### Distributions
- Add slice distribution (#1107)
- Deprecate `rngs::adapter::ReadRng` (#1130)

## [0.8.3] - 2021-01-25
### Fixes
Expand Down Expand Up @@ -678,4 +678,4 @@ when updating from `rand 0.7.0` without also updating `rand_core`.

## [0.10-pre] - 2014-03-02
### Added
- Seperate `rand` out of the standard library
- Separate `rand` out of the standard library
2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rand"
version = "0.8.3"
version = "0.8.4"
authors = ["The Rand Project Developers", "The Rust Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -143,7 +143,7 @@ unavailable.

The WASM target `wasm32-unknown-unknown` is not *automatically* supported by
`rand` or `getrandom`. To solve this, either use a different target such as
`wasm32-wasi` or add a direct dependancy on `getrandom` with the `js` feature
`wasm32-wasi` or add a direct dependency on `getrandom` with the `js` feature
(if the target supports JavaScript). See
[getrandom#WebAssembly support](https://docs.rs/getrandom/latest/getrandom/#webassembly-support).

Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Expand Up @@ -8,7 +8,7 @@ No binding guarantees can be provided.
## Security premises

Rand provides the trait `rand_core::CryptoRng` aka `rand::CryptoRng` as a marker
trait. Generators implementating `RngCore` *and* `CryptoRng`, and given the
trait. Generators implementing `RngCore` *and* `CryptoRng`, and given the
additional constraints that:

- Instances of seedable RNGs (those implementing `SeedableRng`) are
Expand Down
5 changes: 5 additions & 0 deletions rand_core/CHANGELOG.md
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.3] - 2021-06-15
### Changed
- Improved bound for `serde` impls on `BlockRng` (#1130)
- Minor doc additions (#1118)

## [0.6.2] - 2021-02-12
### Fixed
- Fixed assertions in `le::read_u32_into` and `le::read_u64_into` which could
Expand Down
2 changes: 1 addition & 1 deletion rand_core/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rand_core"
version = "0.6.2"
version = "0.6.3"
authors = ["The Rand Project Developers", "The Rust Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion rand_core/src/block.rs
Expand Up @@ -95,7 +95,7 @@ pub trait BlockRngCore {
/// [`fill_bytes`] / [`try_fill_bytes`] is called on a large array. These methods
/// also handle the bookkeeping of when to generate a new batch of values.
///
/// No whole generated `u32` values are thown away and all values are consumed
/// No whole generated `u32` values are thrown away and all values are consumed
/// in-order. [`next_u32`] simply takes the next available `u32` value.
/// [`next_u64`] is implemented by combining two `u32` values, least
/// significant first. [`fill_bytes`] and [`try_fill_bytes`] consume a whole
Expand Down
4 changes: 3 additions & 1 deletion rand_distr/CHANGELOG.md
Expand Up @@ -4,12 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## [0.4.1] - 2021-06-15
- Empirically test PDF of normal distribution (#1121)
- Correctly document `no_std` support (#1100)
- Add `std_math` feature to prefer `std` over `libm` for floating point math (#1100)
- Add mean and std_dev accessors to Normal (#1114)
- Make sure all distributions and their error types implement `Error`, `Display`, `Clone`,
`Copy`, `PartialEq` and `Eq` as appropriate (#1126)
- Port benchmarks to use Criterion crate (#1116)
- Support serde for distributions (#1141)

## [0.4.0] - 2020-12-18
Expand Down
2 changes: 1 addition & 1 deletion rand_distr/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rand_distr"
version = "0.4.0"
version = "0.4.1"
authors = ["The Rand Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion rand_distr/README.md
Expand Up @@ -24,7 +24,7 @@ contrast, this `rand_distr` crate focuses on sampling from distributions.

The floating point functions from `num_traits` and `libm` are used to support
`no_std` environments and ensure reproducibility. If the floating point
functions from `std` are prefered, which may provide better accuracy and
functions from `std` are preferred, which may provide better accuracy and
performance but may produce different random values, the `std_math` feature
can be enabled.

Expand Down
4 changes: 2 additions & 2 deletions rand_distr/src/binomial.rs
Expand Up @@ -106,7 +106,7 @@ impl Distribution<u64> for Binomial {
// random variate generation. Commun. ACM 31, 2 (February 1988),
// 216-222. http://dx.doi.org/10.1145/42372.42381

// Threshold for prefering the BINV algorithm. The paper suggests 10,
// Threshold for preferring the BINV algorithm. The paper suggests 10,
// Ranlib uses 30, and GSL uses 14.
const BINV_THRESHOLD: f64 = 10.;

Expand Down Expand Up @@ -243,7 +243,7 @@ impl Distribution<u64> for Binomial {
}
}

// Step 5.2: Squeezing. Check the value of ln(v) againts upper and
// Step 5.2: Squeezing. Check the value of ln(v) against upper and
// lower bound of ln(f(y)).
let k = k as f64;
let rho = (k / npq) * ((k * (k / 3. + 0.625) + 1. / 6.) / npq + 0.5);
Expand Down
2 changes: 1 addition & 1 deletion rand_distr/src/hypergeometric.rs
Expand Up @@ -30,7 +30,7 @@ enum SamplingMethod {
/// `f(k) = binomial(K, k) * binomial(N-K, n-k) / binomial(N, n)`,
/// where `binomial(a, b) = a! / (b! * (a - b)!)`.
///
/// The [binomial distribution](crate::Binomial) is the analagous distribution
/// The [binomial distribution](crate::Binomial) is the analogous distribution
/// for sampling with replacement. It is a good approximation when the population
/// size is much larger than the sample size.
///
Expand Down
2 changes: 1 addition & 1 deletion rand_distr/src/poisson.rs
Expand Up @@ -110,7 +110,7 @@ where F: Float + FloatConst, Standard: Distribution<F>
loop {
// draw from the Cauchy distribution
comp_dev = rng.sample(cauchy);
// shift the peak of the comparison ditribution
// shift the peak of the comparison distribution
result = self.sqrt_2lambda * comp_dev + self.lambda;
// repeat the drawing until we are in the range of possible values
if result >= F::zero() {
Expand Down
8 changes: 4 additions & 4 deletions rand_distr/src/utils.rs
Expand Up @@ -91,14 +91,14 @@ where
let i = bits as usize & 0xff;

let u = if symmetric {
// Convert to a value in the range [2,4) and substract to get [-1,1)
// Convert to a value in the range [2,4) and subtract to get [-1,1)
// We can't convert to an open range directly, that would require
// substracting `3.0 - EPSILON`, which is not representable.
// subtracting `3.0 - EPSILON`, which is not representable.
// It is possible with an extra step, but an open range does not
// seem neccesary for the ziggurat algorithm anyway.
// seem necessary for the ziggurat algorithm anyway.
(bits >> 12).into_float_with_exponent(1) - 3.0
} else {
// Convert to a value in the range [1,2) and substract to get (0,1)
// Convert to a value in the range [1,2) and subtract to get (0,1)
(bits >> 12).into_float_with_exponent(0) - (1.0 - core::f64::EPSILON / 2.0)
};
let x = u * x_tab[i];
Expand Down
3 changes: 3 additions & 0 deletions rand_hc/CHANGELOG.md
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.1] - 2021-06-15
- Adjust crate links

## [0.3.0] - 2020-12-08
- Bump `rand_core` version to 0.6.0
- Bump MSRV to 1.36 (#1011)
Expand Down
2 changes: 1 addition & 1 deletion rand_hc/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rand_hc"
version = "0.3.0"
version = "0.3.1"
authors = ["The Rand Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions rand_hc/src/hc128.rs
Expand Up @@ -142,7 +142,7 @@ impl BlockRngCore for Hc128Core {
let dd = (cc + 16) % 512;
let ee = cc.wrapping_sub(16) % 512;
// These asserts let the compiler optimize out the bounds checks.
// Some of them may be superflous, and that's fine:
// Some of them may be superfluous, and that's fine:
// they'll be optimized out if that's the case.
assert!(ee + 15 < 512);
assert!(cc + 15 < 512);
Expand Down Expand Up @@ -238,7 +238,7 @@ impl Hc128Core {
let dd = (cc + 16) % 512;
let ee = cc.wrapping_sub(16) % 512;
// These asserts let the compiler optimize out the bounds checks.
// Some of them may be superflous, and that's fine:
// Some of them may be superfluous, and that's fine:
// they'll be optimized out if that's the case.
assert!(ee + 15 < 512);
assert!(cc + 15 < 512);
Expand Down
4 changes: 4 additions & 0 deletions rand_pcg/CHANGELOG.md
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.1] - 2021-06-15
- Add `advance` methods to RNGs (#1111)
- Document dependencies between streams (#1122)

## [0.3.0] - 2020-12-08
- Bump `rand_core` version to 0.6.0
- Bump MSRV to 1.36 (#1011)
Expand Down
2 changes: 1 addition & 1 deletion rand_pcg/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "rand_pcg"
version = "0.3.0"
version = "0.3.1"
authors = ["The Rand Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion rand_pcg/src/pcg128.rs
Expand Up @@ -93,7 +93,7 @@ impl Lcg128Xsl64 {
#[inline]
fn from_state_incr(state: u128, increment: u128) -> Self {
let mut pcg = Lcg128Xsl64 { state, increment };
// Move away from inital value:
// Move away from initial value:
pcg.state = pcg.state.wrapping_add(pcg.increment);
pcg.step();
pcg
Expand Down
2 changes: 1 addition & 1 deletion rand_pcg/src/pcg64.rs
Expand Up @@ -94,7 +94,7 @@ impl Lcg64Xsh32 {
#[inline]
fn from_state_incr(state: u64, increment: u64) -> Self {
let mut pcg = Lcg64Xsh32 { state, increment };
// Move away from inital value:
// Move away from initial value:
pcg.state = pcg.state.wrapping_add(pcg.increment);
pcg.step();
pcg
Expand Down
2 changes: 1 addition & 1 deletion src/distributions/bernoulli.rs
Expand Up @@ -49,7 +49,7 @@ pub struct Bernoulli {
// `f64` only has 53 bits of precision, and the next largest value of `p` will
// result in `2^64 - 2048`.
//
// Also there is a 100% theoretical concern: if someone consistenly wants to
// Also there is a 100% theoretical concern: if someone consistently wants to
// generate `true` using the Bernoulli distribution (i.e. by using a probability
// of `1.0`), just using `u64::MAX` is not enough. On average it would return
// false once every 2^64 iterations. Some people apparently care about this
Expand Down
2 changes: 1 addition & 1 deletion src/distributions/float.rs
Expand Up @@ -78,7 +78,7 @@ pub struct Open01;
pub trait IntoFloat {
type F;

/// Helper method to combine the fraction and a contant exponent into a
/// Helper method to combine the fraction and a constant exponent into a
/// float.
///
/// Only the least significant bits of `self` may be set, 23 for `f32` and
Expand Down
2 changes: 1 addition & 1 deletion src/distributions/uniform.rs
Expand Up @@ -158,7 +158,7 @@ use serde::{Serialize, Deserialize};
/// println!("{}", sum);
/// ```
///
/// For a single sample, [`Rng::gen_range`] may be prefered:
/// For a single sample, [`Rng::gen_range`] may be preferred:
///
/// ```
/// use rand::Rng;
Expand Down
4 changes: 2 additions & 2 deletions src/rngs/thread.rs
Expand Up @@ -33,7 +33,7 @@ use crate::{CryptoRng, Error, RngCore, SeedableRng};


// Number of generated bytes after which to reseed `ThreadRng`.
// According to benchmarks, reseeding has a noticable impact with thresholds
// According to benchmarks, reseeding has a noticeable impact with thresholds
// of 32 kB and less. We choose 64 kB to avoid significant overhead.
const THREAD_RNG_RESEED_THRESHOLD: u64 = 1024 * 64;

Expand All @@ -59,7 +59,7 @@ const THREAD_RNG_RESEED_THRESHOLD: u64 = 1024 * 64;
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "std", feature = "std_rng"))))]
#[derive(Clone, Debug)]
pub struct ThreadRng {
// Rc is explictly !Send and !Sync
// Rc is explicitly !Send and !Sync
rng: Rc<UnsafeCell<ReseedingRng<Core, OsRng>>>,
}

Expand Down

0 comments on commit af751df

Please sign in to comment.