Files
Nim/lib/pure
c-blake 7ac1fc81fd Resolve things raised in https://github.com/nim-lang/Nim/issues/10081 ? (#10084)
* Resolve things raised in https://github.com/nim-lang/Nim/issues/10081 ?
CDF is a standard ident in all things related to random numbers/sampling,
and full words "cumulativeDistributionFunction" would be silly long, in
this case, IMO.  We use lowercase `cdf` to make it not look like a type,
remove all looping from `sample` letting callers do it.  Besides just
side-stepping any `sampleSize` name choice, callers may want to filter
out samples anyway which this makes slightly simpler.

Also add two variants of `cumsum`, value return and in-place update
distinguished by the var-ness of the first argument.  Add tests for
`int` and `float` for both `cumsum` and the new `sample`.  (The sample
tests exercise the value return mode of `cumsum`.)

Functionality pre-this-PR `sample(a, w)` is now the almost as simple
`for i in 0..<n: sample(a, w.cumsum)`, but this new code factoring is
almost surely better.  The statistical tests pass, as before.

* Address Araq comment in https://github.com/nim-lang/Nim/pull/10084
We can always add in some `var` version later if desired to save
memory, but this change now at least firms up the `sample` interface.

* Rename `cumsum` -> `cumsummed` to honor NEP1 style.  Re-instate `cumsum` as
the in-place transformation.  Test both in `tests/stdlib/tmath.nim` and use
`cumsummed` in the example code for sample since that's a simpler example.

* Fix requests from https://github.com/nim-lang/Nim/pull/10084 :
  example in lib/pure/math.nim and comment whitespace in lib/pure/random.nim
2018-12-31 14:52:51 +01: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-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-12-30 02:06:15 +01:00
2018-11-26 18:59:24 +01:00
2017-01-25 20:02:19 +01:00