Files
Nim/tests/stdlib
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-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