Skip to content

Commit a773e44

Browse files
rand: update documentation for normal and normal_pair (#17898)
1 parent 7838ef3 commit a773e44

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

vlib/rand/rand.v

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,16 @@ pub fn (mut rng PRNG) bernoulli(p f64) !bool {
351351
return rng.f64() <= p
352352
}
353353

354-
// normal returns a normally distributed pseudorandom f64 in range `[0, 1)`.
354+
// normal returns a normally distributed pseudorandom f64 with mean `mu` and standard
355+
// deviation `sigma`. By default, `mu` is 0.0 and `sigma` is 1.0.
355356
// NOTE: Use normal_pair() instead if you're generating a lot of normal variates.
356357
pub fn (mut rng PRNG) normal(conf config.NormalConfigStruct) !f64 {
357358
x, _ := rng.normal_pair(conf)!
358359
return x
359360
}
360361

361-
// normal_pair returns a pair of normally distributed pseudorandom f64 in range `[0, 1)`.
362+
// normal_pair returns a pair of normally distributed pseudorandom f64 with mean `mu` and standard
363+
// deviation `sigma`. By default, `mu` is 0.0 and `sigma` is 1.0.
362364
pub fn (mut rng PRNG) normal_pair(conf config.NormalConfigStruct) !(f64, f64) {
363365
if conf.sigma <= 0 {
364366
return error('Standard deviation must be positive')
@@ -714,13 +716,15 @@ pub fn bernoulli(p f64) !bool {
714716
return default_rng.bernoulli(p)
715717
}
716718

717-
// normal returns a normally distributed pseudorandom f64 in range `[0, 1)`.
719+
// normal returns a normally distributed pseudorandom f64 with mean `mu` and standard
720+
// deviation `sigma`. By default, `mu` is 0.0 and `sigma` is 1.0.
718721
// NOTE: Use normal_pair() instead if you're generating a lot of normal variates.
719722
pub fn normal(config_ config.NormalConfigStruct) !f64 {
720723
return default_rng.normal(config_)
721724
}
722725

723-
// normal_pair returns a pair of normally distributed pseudorandom f64 in range `[0, 1)`.
726+
// normal_pair returns a pair of normally distributed pseudorandom f64 with mean `mu` and standard
727+
// deviation `sigma`. By default, `mu` is 0.0 and `sigma` is 1.0.
724728
pub fn normal_pair(config_ config.NormalConfigStruct) !(f64, f64) {
725729
return default_rng.normal_pair(config_)
726730
}

0 commit comments

Comments
 (0)