Files
Nim/lib/pure
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-08-30 16:54:03 +02:00
2018-04-30 02:52:58 +02:00
2018-11-07 10:58:48 +01:00
2018-04-30 02:52:58 +02:00
2015-10-01 12:05:45 -07:00
2018-04-15 23:38:43 +02:00
2018-06-27 12:35:09 +02:00
2018-11-16 13:27:56 +01:00
2018-08-14 09:35:07 +02:00
2018-04-06 11:59:49 +02:00
2018-04-30 02:52:58 +02:00
2018-10-31 14:09:39 +02:00
2018-10-19 11:45:59 +02:00
2018-12-21 14:28:52 +01:00
2018-12-19 11:25:50 +01:00
2016-07-21 08:53:10 +01:00
2018-12-16 20:34:07 +01:00
2018-11-16 13:27:56 +01:00
2018-12-05 11:27:22 -08:00
2018-11-16 13:27:56 +01:00
2016-07-21 08:52:39 +01:00
2017-03-26 09:30:59 +02:00
2018-07-25 09:07:50 +03:00
2018-11-16 11:30:34 +01:00
2015-02-03 09:04:24 +01:00
2018-10-28 13:35:30 +01:00
2018-12-19 18:06:13 +01:00
2018-10-29 10:06:36 +01:00
2018-11-16 13:27:56 +01:00
2018-11-26 18:59:24 +01:00
2017-01-25 20:02:19 +01:00