File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 23
23
use num;
24
24
use rand:: { Rng , Rand } ;
25
25
26
+ /// Things that can be used to create a random instance of `Support`.
27
+ pub trait Sample < Support > {
28
+ /// Generate a random value of `Support`, using `rng` as the
29
+ /// source of randomness.
30
+ fn sample < R : Rng > ( & mut self , rng : & mut R ) -> Support ;
31
+ }
32
+
33
+ /// `Sample`s that do not require keeping track of state, so each
34
+ /// sample is (statistically) independent of all others, assuming the
35
+ /// `Rng` used has this property.
36
+ // XXX maybe having this separate is overkill (the only reason is to
37
+ // take &self rather than &mut self)? or maybe this should be the
38
+ // trait called `Sample` and the other should be `DependentSample`.
39
+ pub trait IndependentSample < Support > : Sample < Support > {
40
+ /// Generate a random value.
41
+ fn ind_sample < R : Rng > ( & self , & mut R ) -> Support ;
42
+ }
43
+
26
44
mod ziggurat_tables;
27
45
28
46
// inlining should mean there is no performance penalty for this
You can’t perform that action at this time.
0 commit comments