@@ -17,7 +17,7 @@ use self::ChiSquaredRepr::*;
17
17
18
18
use { Rng } ;
19
19
use dist:: normal:: standard_normal;
20
- use dist:: { Sample , Exp , open01} ;
20
+ use dist:: { Distribution , Exp , open01} ;
21
21
22
22
/// The Gamma distribution `Gamma(shape, scale)` distribution.
23
23
///
@@ -38,7 +38,7 @@ use dist::{Sample, Exp, open01};
38
38
/// # Example
39
39
///
40
40
/// ```rust
41
- /// use rand::dist::{Sample , Gamma};
41
+ /// use rand::dist::{Distribution , Gamma};
42
42
///
43
43
/// let gamma = Gamma::new(2.0, 5.0);
44
44
/// let v = gamma.sample(&mut rand::thread_rng());
@@ -134,7 +134,7 @@ impl GammaLargeShape {
134
134
}
135
135
136
136
137
- impl Sample < f64 > for Gamma {
137
+ impl Distribution < f64 > for Gamma {
138
138
fn sample < R : Rng > ( & self , rng : & mut R ) -> f64 {
139
139
match self . repr {
140
140
Small ( ref g) => g. sample ( rng) ,
@@ -143,14 +143,14 @@ impl Sample<f64> for Gamma {
143
143
}
144
144
}
145
145
}
146
- impl Sample < f64 > for GammaSmallShape {
146
+ impl Distribution < f64 > for GammaSmallShape {
147
147
fn sample < R : Rng > ( & self , rng : & mut R ) -> f64 {
148
148
let u: f64 = open01 ( rng) ;
149
149
150
150
self . large_shape . sample ( rng) * u. powf ( self . inv_shape )
151
151
}
152
152
}
153
- impl Sample < f64 > for GammaLargeShape {
153
+ impl Distribution < f64 > for GammaLargeShape {
154
154
fn sample < R : Rng > ( & self , rng : & mut R ) -> f64 {
155
155
loop {
156
156
let x = standard_normal ( rng) ;
@@ -182,7 +182,7 @@ impl Sample<f64> for GammaLargeShape {
182
182
/// # Example
183
183
///
184
184
/// ```rust
185
- /// use rand::dist::{ChiSquared, Sample };
185
+ /// use rand::dist::{ChiSquared, Distribution };
186
186
///
187
187
/// let chi = ChiSquared::new(11.0);
188
188
/// let v = chi.sample(&mut rand::thread_rng());
@@ -215,7 +215,7 @@ impl ChiSquared {
215
215
ChiSquared { repr : repr }
216
216
}
217
217
}
218
- impl Sample < f64 > for ChiSquared {
218
+ impl Distribution < f64 > for ChiSquared {
219
219
fn sample < R : Rng > ( & self , rng : & mut R ) -> f64 {
220
220
match self . repr {
221
221
DoFExactlyOne => {
@@ -237,7 +237,7 @@ impl Sample<f64> for ChiSquared {
237
237
/// # Example
238
238
///
239
239
/// ```rust
240
- /// use rand::dist::{FisherF, Sample };
240
+ /// use rand::dist::{FisherF, Distribution };
241
241
///
242
242
/// let f = FisherF::new(2.0, 32.0);
243
243
/// let v = f.sample(&mut rand::thread_rng());
@@ -266,7 +266,7 @@ impl FisherF {
266
266
}
267
267
}
268
268
}
269
- impl Sample < f64 > for FisherF {
269
+ impl Distribution < f64 > for FisherF {
270
270
fn sample < R : Rng > ( & self , rng : & mut R ) -> f64 {
271
271
self . numer . sample ( rng) / self . denom . sample ( rng) * self . dof_ratio
272
272
}
@@ -278,7 +278,7 @@ impl Sample<f64> for FisherF {
278
278
/// # Example
279
279
///
280
280
/// ```rust
281
- /// use rand::dist::{StudentT, Sample };
281
+ /// use rand::dist::{StudentT, Distribution };
282
282
///
283
283
/// let t = StudentT::new(11.0);
284
284
/// let v = t.sample(&mut rand::thread_rng());
@@ -301,7 +301,7 @@ impl StudentT {
301
301
}
302
302
}
303
303
}
304
- impl Sample < f64 > for StudentT {
304
+ impl Distribution < f64 > for StudentT {
305
305
fn sample < R : Rng > ( & self , rng : & mut R ) -> f64 {
306
306
let norm = standard_normal ( rng) ;
307
307
norm * ( self . dof / self . chi . sample ( rng) ) . sqrt ( )
@@ -310,7 +310,7 @@ impl Sample<f64> for StudentT {
310
310
311
311
#[ cfg( test) ]
312
312
mod test {
313
- use dist:: { Sample } ;
313
+ use dist:: { Distribution } ;
314
314
use super :: { ChiSquared , StudentT , FisherF } ;
315
315
316
316
#[ test]
0 commit comments