kaupifalco has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to generate a couple of things here. First I wrote a program that allows me to determine the generations that is needed for two lineages to meet back in time (evolving lineages). I'm assuming a mean of 4N/(k(k-1), with k= 2 and N=10000. My program is working and this is the script:
$k = 25; $N = 10000; while ($k>=2) { if ($k==1) {last;} $mean = (4*$N)/($k*($k-1)); $time = (-log(rand)*$mean); push (@cls, $time); $k=$k-1; } open (GENE,'>coal.xls'); for ($time=0; $time<24; $time ++) { print GENE "@cls[$time]\n"; }
Now I need to write a simulation using an exponential distribution built from 5000 numbers, and afterwards get the mean, and the number of estimates above and below the mean. For this I need to use the same program as above. Although it is not working. So far this is my non-working scrypt:
Thanks in advance!#!usr/bin/perl use warnings; for ($sample=0; $sample<5000; $sample ++) { $k = 25; $N = 10000; @cls=(); $total=0; while ($k>=2) { if ($k==1) {last;} $mean = (4*$N)/($k*($k-1)); $time = (-log(rand)*$mean); push (@cls, $time); $k=$k-1; } $ntotal+=$_ for @first; $nmean = $ntotal/5000; print "$nmean\n"; foreach $first(@first) { if ($first<=$nmean) {push(@low, $first)}} $low= scalar @low; $hig= scalar (5000-@low); print "$low\n"; print "$hig\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: help finding mean, numbers above and below mean from an exponential distribution
by almut (Canon) on Oct 13, 2009 at 02:18 UTC | |
|
Re: help finding mean, numbers above and below mean from an exponential distribution
by GrandFather (Saint) on Oct 13, 2009 at 04:07 UTC | |
|
Re: help finding mean, numbers above and below mean from an exponential distribution
by biohisham (Priest) on Oct 13, 2009 at 11:11 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |