Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Probability sum of random variables

by Prof Vince (Friar)
on Aug 31, 2007 at 10:03 UTC ( #636284=note: print w/ replies, xml ) Need Help??


in reply to Probability sum of random variables

The distribution of the sum of two independant random variables is (IIRC) the convolution product of the distributions. From that, it's rather simple to compute it :

use List::Util qw/sum/; my @a; # holds the known distribution sub conv { my ($n) = @_; return sum map { ($_ < @a) ? ((($n - $_) < @a) ? $a[$_] * $a[$n - $_] : 0) : 0 } 0 .. $n; }
If you want the distribution of the sum of n random variables, you can adapt this code to accept two distributions and recursively compute the n-th convolution product of @a.


Comment on Re: Probability sum of random variables
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://636284]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2014-07-30 23:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (241 votes), past polls