Files
Nim/tests/stdlib
c-blake e1d5356ae9 Add ability to sample elements from openArray according to a weight array (#10072)
* Add the ability to sample elements from an openArray according to a parallel
array of weights/unnormalized probabilities (any sort of histogram, basically).
Also add a non-thread safe version for convenience.

* Address Araq comments on https://github.com/nim-lang/Nim/pull/10072

* import at top of file and space after '#'.

* Put in a check for non-zero total weight.

* Clarify constraint on `w`.

* Rename `rand(openArray[T])` to `sample(openArray[T])` to `sample`, deprecating
old name and name new (openArray[T], openArray[U]) variants `sample`.

* Rename caller-provided state version of rand(openArray[T]) and also clean
up doc comments.

* Add test for new non-uniform array sampler.  3 sd bound makes it 99% likely
that it will still pass in the future if the random number generator changes.
We cannot both have a tight bound to check distribution *and* loose check to
ensure resilience to RNG changes.  (We cannot *guarantee* resilience, anyway.
There's always a small chance any test hits a legitimate random fluctuation.)
2018-12-23 12:23:20 +00:00
..
2018-01-14 23:49:53 +01:00
2018-11-23 11:58:28 +01:00
2017-11-15 17:25:48 +01:00
2018-11-23 11:58:28 +01:00
2018-12-11 21:23:22 +01:00
2018-11-27 10:34:34 +01:00
2018-11-23 11:58:31 +01:00
2015-03-31 00:32:39 +02:00
2018-10-12 17:27:47 +02:00
2018-12-13 16:19:00 +01:00
2017-05-04 22:25:29 +02:00
2018-11-23 11:58:29 +01:00
2018-12-11 21:23:21 +01:00
2018-12-11 21:23:21 +01:00
2018-11-23 11:58:32 +01:00
2018-06-05 00:09:07 -04:00
2018-10-28 13:35:30 +01:00
2014-08-29 09:12:12 +02:00
2018-09-03 10:16:11 +02:00
2018-04-30 11:16:56 +02:00