@@ -32,13 +32,13 @@ use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
3232pub struct StandardNormal ( pub f64 ) ;
3333
3434impl Rand for StandardNormal {
35- fn rand < R : Rng > ( rng : & mut R ) -> StandardNormal {
35+ fn rand < R : Rng > ( rng : & mut R ) -> StandardNormal {
3636 #[ inline]
3737 fn pdf ( x : f64 ) -> f64 {
38- ( -x* x/ 2.0 ) . exp ( )
38+ ( -x * x / 2.0 ) . exp ( )
3939 }
4040 #[ inline]
41- fn zero_case < R : Rng > ( rng : & mut R , u : f64 ) -> f64 {
41+ fn zero_case < R : Rng > ( rng : & mut R , u : f64 ) -> f64 {
4242 // compute a random number in the tail by hand
4343
4444 // strange initial conditions, because the loop is not
@@ -56,15 +56,19 @@ impl Rand for StandardNormal {
5656 y = y_. ln ( ) ;
5757 }
5858
59- if u < 0.0 { x - ziggurat_tables:: ZIG_NORM_R } else { ziggurat_tables:: ZIG_NORM_R - x }
59+ if u < 0.0 {
60+ x - ziggurat_tables:: ZIG_NORM_R
61+ } else {
62+ ziggurat_tables:: ZIG_NORM_R - x
63+ }
6064 }
6165
62- StandardNormal ( ziggurat (
63- rng ,
64- true , // this is symmetric
65- & ziggurat_tables:: ZIG_NORM_X ,
66- & ziggurat_tables :: ZIG_NORM_F ,
67- pdf , zero_case) )
66+ StandardNormal ( ziggurat ( rng ,
67+ true , // this is symmetric
68+ & ziggurat_tables :: ZIG_NORM_X ,
69+ & ziggurat_tables:: ZIG_NORM_F ,
70+ pdf ,
71+ zero_case) )
6872 }
6973}
7074
@@ -89,12 +93,14 @@ impl Normal {
8993 assert ! ( std_dev >= 0.0 , "Normal::new called with `std_dev` < 0" ) ;
9094 Normal {
9195 mean : mean,
92- std_dev : std_dev
96+ std_dev : std_dev,
9397 }
9498 }
9599}
96100impl Sample < f64 > for Normal {
97- fn sample < R : Rng > ( & mut self , rng : & mut R ) -> f64 { self . ind_sample ( rng) }
101+ fn sample < R : Rng > ( & mut self , rng : & mut R ) -> f64 {
102+ self . ind_sample ( rng)
103+ }
98104}
99105impl IndependentSample < f64 > for Normal {
100106 fn ind_sample < R : Rng > ( & self , rng : & mut R ) -> f64 {
@@ -110,7 +116,7 @@ impl IndependentSample<f64> for Normal {
110116/// std_dev**2)` distributed.
111117#[ derive( Copy , Clone ) ]
112118pub struct LogNormal {
113- norm : Normal
119+ norm : Normal ,
114120}
115121
116122impl LogNormal {
@@ -126,7 +132,9 @@ impl LogNormal {
126132 }
127133}
128134impl Sample < f64 > for LogNormal {
129- fn sample < R : Rng > ( & mut self , rng : & mut R ) -> f64 { self . ind_sample ( rng) }
135+ fn sample < R : Rng > ( & mut self , rng : & mut R ) -> f64 {
136+ self . ind_sample ( rng)
137+ }
130138}
131139impl IndependentSample < f64 > for LogNormal {
132140 fn ind_sample < R : Rng > ( & self , rng : & mut R ) -> f64 {
@@ -179,7 +187,7 @@ mod bench {
179187 use std:: prelude:: v1:: * ;
180188 use self :: test:: Bencher ;
181189 use std:: mem:: size_of;
182- use distributions:: { Sample } ;
190+ use distributions:: Sample ;
183191 use super :: Normal ;
184192
185193 #[ bench]
0 commit comments