Post Reply 
define a formula
03-09-2014, 11:40 PM
Post: #2
RE: define a formula
Unless you absolutely want to write a function for that (for learning purposes maybe) you don't have to:
1. You could use the mean(L,p) function where L is the list of values and p the list of probabilities.
2. Or if you write L and p as vectors you could just calculate the dot product of the vectors L and p: [L1, L2, L3,...]*[p1, p2, p3...]

If p1, p2, etc are not probabilities in range 0 to 1, but frequencies instead (e.g. 3 times, 7 times etc) for method 2 you should also divide by sum(p): E(X)=L*p/sum(p)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
define a formula - fefer92 - 03-09-2014, 10:44 PM
RE: define a formula - Stefan - 03-09-2014 11:40 PM
RE: define a formula - fefer92 - 03-09-2014, 11:56 PM
RE: define a formula - Stefan - 03-10-2014, 12:10 AM
RE: define a formula - fefer92 - 03-10-2014, 01:05 AM
RE: define a formula - Stefan - 03-10-2014, 01:38 AM



User(s) browsing this thread: 1 Guest(s)