daverave has asked for the wisdom of the Perl Monks concerning the following question:
The following piece of code randomly maps a set of ranges onto a circumference of a circle. In the example, the circumference is of length 1000 and legal ranges are e.g. (0,8)=0,1,2,...,8 and (995,2)=995,996,...,999,0,1,2 (i.e. zero-based coordinates; both start and end are inclusive).
I take some arbitrary position on the circumference (e.g. 36) and count how many ranges cover it in each simulation.
finally, I calculate the mean and variance of this statistic.
use strict; use warnings; use Statistics::Descriptive; my $n_simulations = 1000; my $circumference = 1000; my @lengths_distrib = (100) x 100; # distibution of range lengt +hs my $some_pos = 36; # arbitrary position my $stat = Statistics::Descriptive::Full->new(); foreach my $sim ( 1 .. $n_simulations ) { # randomly map ranges onto circumference my @random_ranges = map { my $start = int( rand($circumference) ); [ $start, ( + $start + $_ -1 ) % $circumference ] } @lengths_distrib; # count how many range contain $some_pos my $num_covering_ranges = scalar( grep { ( $_->[0] <= $some_pos and $_->[1] >= $some_pos ) o +r ( $_->[1] < $_->[0] and $_->[1] > $some_pos ) } @random_ranges ); $stat->add_data($num_covering_ranges); } print $stat->mean, ' ', $stat->variance, "\n";
To the best of my knowledge, this kind of random variable should follow Poisson distribution (law of rare events and so on). Hence, the mean and variance should be equal. However, the variance seems to systematically be a bit lower than the mean.
What am I missing?
UPDATE: this question is now also shared with the guys at CrossValidated (http://stats.stackexchange.com/questions/5005/).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unexpected under-dispersion in random simulations
by BrowserUk (Patriarch) on Nov 29, 2010 at 22:18 UTC | |
by daverave (Scribe) on Nov 30, 2010 at 08:34 UTC | |
by BrowserUk (Patriarch) on Nov 30, 2010 at 09:40 UTC | |
|
Re: Unexpected under-dispersion in random simulations
by blakew (Monk) on Nov 29, 2010 at 23:43 UTC | |
|
Re: Unexpected under-dispersion in random simulations
by Illuminatus (Curate) on Nov 29, 2010 at 21:00 UTC | |
by daverave (Scribe) on Nov 29, 2010 at 21:11 UTC | |
by GrandFather (Saint) on Nov 30, 2010 at 19:57 UTC | |
by BrowserUk (Patriarch) on Nov 30, 2010 at 20:26 UTC |