Post Reply 
Distributions
02-22-2015, 06:49 PM (This post was last modified: 02-22-2015 07:04 PM by salvomic.)
Post: #9
RE: Distributions
Another, that requires a bit of attention...
see here for the definition.
See also this thread for the multinomial coefficient.

Multinomial distribution (requires n = total number of items, list of k items of a kind, list of their probabilities...)

Code:

EXPORT Multinomd(n, k, p)
// Multinomial distribution (n>0,{list k_i}, {list p_i})
BEGIN

IF ((type(k) ≠ 6) OR (type(p) ≠ 6)) THEN 
return "2nd and 3th argument must be a list"; ELSE
IF n<1 THEN return "n must be >0"; END;
n:= ip(n); //n must be integer
IF (size(k) ≠ size(p) ) THEN return "items in k must be = those in p"; END;
IF (ΣList(k) ≠ n) THEN return "ΣList(k) must be = n"; END;
IF (ΣList(p) > 1) THEN return "ΣList(p) must be <= 1"; END;
// ΣList(p) should be = 1 but we can use in list k only values with no 0
//so items in p could be less than those in k...
return  (n!/ΠLIST(k!))*ΠLIST(p^k);
END; // if 

END;

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Distributions - salvomic - 02-18-2015, 11:10 PM
RE: Distributions - walter b - 02-19-2015, 06:18 AM
RE: Distributions - parisse - 02-19-2015, 07:35 AM
RE: Distributions - salvomic - 02-19-2015, 08:28 AM
RE: Distributions - Offroad - 02-19-2015, 11:58 AM
RE: Distributions - salvomic - 02-19-2015, 12:38 PM
RE: Distributions - salvomic - 02-19-2015, 03:58 PM
RE: Distributions - salvomic - 02-19-2015, 08:27 PM
RE: Distributions - salvomic - 02-22-2015 06:49 PM
RE: Distributions - salvomic - 03-01-2015, 05:05 PM
RE: Distributions - salvomic - 03-04-2015, 02:37 PM
RE: Distributions - salvomic - 04-08-2015, 11:00 AM
RE: Distributions - DrD - 04-08-2015, 01:22 PM
RE: Distributions - salvomic - 04-08-2015, 01:37 PM
RE: Distributions - Claudio L. - 04-08-2015, 10:04 PM
RE: Distributions - salvomic - 04-09-2015, 04:35 AM
RE: Distributions - Gerald H - 04-09-2015, 09:34 AM
RE: Distributions - Paul Dale - 04-08-2015, 09:33 PM
RE: Distributions - debrouxl - 04-09-2015, 05:53 PM



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