Commit graph

218 commits

Author SHA1 Message Date
Joseph Rushton Wakeling
bc386eed72 Spread long statements across several lines. 2013-06-16 15:53:46 +01:00
Joseph Rushton Wakeling
643a2565a1 More formatting corrections. 2013-06-16 15:48:15 +01:00
Joseph Rushton Wakeling
22d26ef8c1 Simplify assert conditions. 2013-06-16 15:26:56 +01:00
Joseph Rushton Wakeling
91b2c664c7 Fix up spacing and brackets for if statements. 2013-06-16 15:21:04 +01:00
Joseph Rushton Wakeling
ca7abe9454 Indentation corrections. :-( 2013-06-09 16:34:05 +02:00
Joseph Rushton Wakeling
a998d02498 RandomSample assertions to ensure skip sizes respect number of items remaining. 2013-06-09 16:18:53 +02:00
Joseph Rushton Wakeling
8da0f13596 Issue 10269 - RandomSample should use popFrontExactly, not popFrontN, when skipping across input range
This small tweak has been accompanied by a couple of extra checks
to ensure that users do not request more sample points than are
available in the input, which could otherwise be the source of
exceptions.

There exists one remaining case where RandomSample may fail: if it
is given an InputRange without the .length property, and the user
indicates that the total number of items available is greater
than what the InputRange actually contains.  In this case an
exception is thrown from std.array.popFront() line 450,
"Attempting to popFront() past the end of an array", or from
std.array.front() line 624, "Attempting to fetch the front of an
empty array."
2013-06-09 15:23:30 +02:00
Joseph Rushton Wakeling
004ce96368 Unittests for randomSample being passed an InputRange.
The assignment of _input = input has been moved from
initialize() to the constructors so as to avoid
problems with nested structs.
2013-06-04 21:54:14 +02:00
Joseph Rushton Wakeling
cbdd14b57b Issue 10265 - RandomSample fails when passed an InputRange as input
* Issue fixed by making presence of save() property conditional
   on input being a ForwardRange.
2013-06-04 19:27:58 +02:00
Walter Bright
a2c9066282 immutable should be an enum 2013-05-25 13:32:53 -07:00
Nils Boßung
4238f5b3ce add an overload for uniform!enum that takes a generator 2013-04-06 23:01:37 +02:00
Timothee Cour
a983cd6d79 Update random.d
fixed spacing
2013-03-12 18:21:47 -07:00
Timothee Cour
e3221dd626 Update random.d
fix wrong usage in doc example (Random gen(unpredictableSeed)).
2013-03-12 16:44:55 -07:00
Andrej Mitrovic
c95100ba78 Fixes Issue 9339 - Uniform for enums. 2013-01-22 02:20:43 +01:00
k-hara
01df2f60be Remove redundant parenthesis for getters, and use assignment syntax for setters 2012-11-23 15:07:17 +09:00
dsimcha
f2c17d9b0d Add std.random.partialShuffle. 2012-07-25 21:37:41 -04:00
Andrei Alexandrescu
92335506d3 Merge pull request #654 from dawgfoto/fix8314
fix issue 8314
2012-07-22 19:50:22 -07:00
jmdavis
735c2adbda Changes required for issue# 6277. 2012-07-21 01:57:28 -07:00
Martin Nowak
aa896e08cc set random generator in constructor
- Bug 8314 was already fixed by adding a _first flag
2012-07-20 16:34:49 +02:00
jmdavis
28781bfb9f Old deprecations which were not properly taken care of previously. 2012-07-07 02:03:49 -07:00
Andrei Alexandrescu
ae15e0ec14 Merge pull request #553 from WebDrake/master
Rewrite of RandomSample to use Jeffrey Scott Vitter's Algorithm D.
2012-07-01 19:14:52 -07:00
Johannes Pfau
589218003d Fix isSeedable documentation 2012-06-18 14:52:44 +02:00
Johannes Pfau
c0be641cd5 Add seed(InputRange) overload to MersenneTwisterEngine 2012-06-17 13:26:49 +02:00
Joseph Rushton Wakeling
205c3bf4cb Fix problem of first sample point always being identical. 2012-05-09 20:57:52 +02:00
Joseph Rushton Wakeling
5f539a1622 Fix link errors in Ddoc comments. 2012-05-04 20:19:44 +02:00
Joseph Rushton Wakeling
d7f5bb0aa5 Small typo correction in comment/doc. 2012-05-04 20:07:10 +02:00
Joseph Rushton Wakeling
40a79b32e2 RandomSample should check if input is InputRange. 2012-05-04 19:04:52 +02:00
Joseph Rushton Wakeling
56ef13997e Bring code in line with D style. 2012-05-04 14:22:34 +02:00
Joseph Rushton Wakeling
39bc5ae412 skip() and skipA() should not be called as properties.
Ensures code builds with -property and -unittest flags
both enabled.
2012-05-04 12:56:59 +02:00
jmdavis
76def7af85 Fix Issue# 8026.
I added template constraints to all of the templates missing template
constraints in std.random - including randomShuffle, per the bug.
2012-05-03 19:47:15 -07:00
jmdavis
088a228b34 Fixed incorrectly named enum. 2012-05-03 19:40:40 -07:00
jmdavis
1b14818170 Fixed incorrect braces in std.random. 2012-05-03 19:13:23 -07:00
jmdavis
cdd6a858b5 Remove unneeded C stuff and trailing whitespace from std.random. 2012-05-03 19:00:17 -07:00
Joseph Rushton Wakeling
34c7d2f9ec Tweaks to authorship & comments. 2012-04-26 22:27:23 +02:00
Joseph Rushton Wakeling
a47707a197 Rewrite of RandomSample to use Jeffrey Scott Vitter's Algorithm D.
This algorithm calculates a random sample of size n in O(n) time,
generating O(n) random variates, as opposed to the previously
implemented Algorithm S where both scale with the size of the
data being sampled.

Variable names in the implementation follow those in Vitter's
papers introducing the algorithm:

  * Vitter, J. S. (1984) Faster methods for random sampling.
    Commun. ACM 27(7): 703--718.

  * Vitter, J. S. (1987) An efficient algorithm for sequential
    random sampling.  ACM Trans. Math. Softw. 13(1): 58--67.
2012-04-24 17:45:12 +02:00
Andrei Alexandrescu
d2a605d8ec Merge pull request #398 from jpf91/isRNG
Add isRandomNumberGenerator template
2012-04-07 13:37:54 -07:00
James Miller
fba8c66dfa Fixes typo in randomShuffle documentation 2012-03-28 19:04:09 +13:00
Johannes Pfau
d99c33c8c7 Rename isRandomNumberGenerator to isUniformRNG 2012-02-21 19:22:35 +01:00
Johannes Pfau
58ea0229d2 Merge branch 'master' into isRNG 2012-02-21 19:10:46 +01:00
Johannes Pfau
1c07d0a2cd Reimplement isRandomNumberGenerator 2012-02-08 17:16:17 +01:00
Johannes Pfau
324b541d6f Add isRandomNumberGenerator template 2012-01-19 12:59:23 +01:00
Daniel Green
58f4356ca2 Change version( Win32 ) to version( Windows ) when Win64 would be supported as well. 2012-01-16 22:10:18 -05:00
Brad Roberts
532b26e6e0 Merge pull request #348 from CyberShadow/std-random-randomsample
std.random: Fix documentation and one of randomSample's overloads.
2011-12-18 03:39:57 -08:00
Vladimir Panteleev
e18c9d6435 std.random: Fix documentation and one of randomSample's overloads. 2011-12-05 12:04:00 +02:00
David Nadlinger
e312f9898b Strict @property syntax compliance.
This enables the test suite to build with the -property switch enabled.

std.cpuid: vendor()/processor() have not been converted to properties in accordance to core.cpuid.
std.xml: Element.text() cannot be a property due to the optional parameter.
2011-12-04 09:56:14 +01:00
Laurie Clark-Michalek
41c4d79a71 Fixed typo in documentation for dice function in std.random 2011-10-27 01:30:27 +02:00
dsimcha
e7e12c0d57 Make c'tor public again 2011-10-19 09:25:57 -04:00
dsimcha
8d1222b9ae Make c'tor private since people should use free functions. 2011-10-14 20:51:23 -04:00
dsimcha
2b04619816 Bug 6802: RandomSample should take a generator as an argument 2011-10-12 22:37:08 -04:00
Brad Roberts
4aded5d345 break std.random's dependency on std.datetime 2011-10-02 23:37:55 -07:00