Rev 4482 | Rev 18193 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
20 | reyssat | 1 | !if $wims_read_parm!=slib_header |
13586 | bpr | 2 | !goto proc |
20 | reyssat | 3 | !endif |
4161 | bpr | 4 | |
20 | reyssat | 5 | slib_parms=3\ |
6 | ,m\ |
||
7 | ,n\ |
||
8 | ,p |
||
4330 | bpr | 9 | slib_author=Adeline, Grelot |
4161 | bpr | 10 | |
4482 | bpr | 11 | slib_example=5,10,0.5 |
3265 | bpr | 12 | slib_require=pari |
3307 | bpr | 13 | !exit |
14 | |||
20 | reyssat | 15 | :proc |
16 | slib_out= |
||
17 | |||
18 | !distribute item $wims_read_parm into slib_m, slib_n, slib_p |
||
19 | slib_u=!random 0,1 repeat $slib_m |
||
20 | slib_C=!values x for x=0 to $[$slib_n] |
||
21 | |||
22 | slib_out=!exec pari {slib_g(p,x,m)=local(L,u,q,i,k) ;L=listcreate(m);\ |
||
23 | for(k=1,m,u=[$slib_u][k];q=p[1];i=1;\ |
||
4328 | bpr | 24 | if(u<q,listput(L,x[1]),while(u>=q,i=i+1;q+=p[i]);listput(L,x[i])));L};\ |
20 | reyssat | 25 | {slib_bino(n,p,m)=local(q,b,prob);b=listcreate(n+1);\ |
26 | q=p/(1-p);prob=(1-p)^n;listput(b,prob);\ |
||
27 | for(i=1,n,prob=prob*(n-i+1)/i*q;listput(b,prob));\ |
||
4328 | bpr | 28 | print(Vec(slib_g(b,[$slib_C],m)))};\ |
20 | reyssat | 29 | print(slib_bino($slib_n,$slib_p,$slib_m)); |
30 | |||
31 | slib_out =!word 1 to -2 of $slib_out |
||
32 | slib_out=!declosing $slib_out |
||
33 | slib_out=!trim $slib_out |
||
34 |