File tree Expand file tree Collapse file tree 4 files changed +11
-9
lines changed Expand file tree Collapse file tree 4 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -95,8 +95,8 @@ mod tests {
9595 fn value_stability ( ) {
9696 let mut rng = :: test:: rng ( 2 ) ;
9797 let dist = UnitCircle :: new ( ) ;
98- assert_eq ! ( dist. sample( & mut rng) , [ -0.8150602311723979 , 0.5793762331690843 ] ) ;
99- assert_eq ! ( dist. sample( & mut rng) , [ -0.056204569973983196 , 0.998419273809375 ] ) ;
100- assert_eq ! ( dist. sample( & mut rng) , [ 0.7761923749562624 , - 0.630496151502733 ] ) ;
98+ assert_eq ! ( dist. sample( & mut rng) , [ -0.8032118336637037 , 0.5956935036263119 ] ) ;
99+ assert_eq ! ( dist. sample( & mut rng) , [ -0.4742919588505423 , - 0.880367615130018 ] ) ;
100+ assert_eq ! ( dist. sample( & mut rng) , [ 0.9297328981467168 , 0.368234623716601 ] ) ;
101101 }
102102}
Original file line number Diff line number Diff line change @@ -91,10 +91,10 @@ mod tests {
9191 let mut rng = :: test:: rng ( 2 ) ;
9292 let dist = UnitSphereSurface :: new ( ) ;
9393 assert_eq ! ( dist. sample( & mut rng) ,
94- [ 0.1660727273690104 , 0.5202698793511903 , 0.8376986939610902 ] ) ;
94+ [ - 0.24950027180862533 , - 0.7552572587896719 , 0.6060825747478084 ] ) ;
9595 assert_eq ! ( dist. sample( & mut rng) ,
96- [ 0.40052443371799834 , 0.4237054996596154 , -0.812436968356975 ] ) ;
96+ [ 0.47604534507233487 , - 0.797200864987207 , -0.3712837328763685 ] ) ;
9797 assert_eq ! ( dist. sample( & mut rng) ,
98- [ 0.9209910250970449 , - 0.32692477745072107 , 0.21188610520628948 ] ) ;
98+ [ 0.9795722330927367 , 0.18692349236651176 , 0.07414747571708524 ] ) ;
9999 }
100100}
Original file line number Diff line number Diff line change @@ -1102,7 +1102,8 @@ mod test {
11021102 sum += 1 ;
11031103 }
11041104 }
1105- let avg = ( sum as f64 ) / ( N as f64 ) ;
1106- assert ! ( ( avg - ( NUM as f64 ) /( DENOM as f64 ) ) . abs( ) < 1e-3 ) ;
1105+ // Have Binomial(N, NUM/DENOM) distribution
1106+ let expected = ( NUM * N ) / DENOM ; // exact integer
1107+ assert ! ( ( ( sum - expected) as i32 ) . abs( ) < 500 ) ;
11071108 }
11081109}
Original file line number Diff line number Diff line change @@ -616,8 +616,9 @@ mod test {
616616 chosen[ picked] += 1 ;
617617 }
618618 for count in chosen. iter ( ) {
619+ // Samples should follow Binomial(1000, 1/9)
619620 let err = * count - 1000 / 9 ;
620- assert ! ( -25 <= err && err <= 25 ) ;
621+ assert ! ( -30 <= err && err <= 30 ) ;
621622 }
622623 }
623624
You can’t perform that action at this time.
0 commit comments