Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- ini_set('memory_limit','1000M');
- $n = 100000;
- $children = array();
- for($i = 0; $i<$n; $i++)
- {
- $children[$i]['f'] = array('sex' => rand(0,1),'day' => rand(0,6));
- $children[$i]['s'] = array('sex' => rand(0,1),'day' => rand(0,6));
- }
- foreach($children as $i => $child)
- {
- if( ($child['f']['sex'] == 0 && $child['f']['day'] == 0) || ( $child['s']['sex'] == 0 && $child['s']['day'] == 0))
- {
- $condition[] = $child;
- }
- }
- echo "n: $n, sample size: ".count($condition)."\n";
- foreach($condition as $child)
- {
- if($child['f']['sex'] == 0 && $child['s']['sex'] == 0)
- {
- $both++;
- }
- }
- echo "both boys: $both\n";
- echo "pct: ".$both/count($condition)."\n";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement