Subversion Repositories wimsdev

Rev

Rev 13586 | Rev 18195 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13586 Rev 18193
Line 6... Line 6...
6
 ,m\
6
 ,m\
7
 ,n\
7
 ,n\
8
 ,p
8
 ,p
9
slib_author=Adeline, Grelot
9
slib_author=Adeline, Grelot
10
 
10
 
11
slib_example=5,10,0.5
11
slib_example=5,10,0.5\
-
 
12
5,10,1\
-
 
13
5,11,1.5
-
 
14
 
12
slib_require=pari
15
slib_require=pari
13
!exit
16
!exit
14
 
17
 
15
:proc
18
:proc
16
slib_out=
19
slib_out=
17
 
20
 
18
!distribute item $wims_read_parm into slib_m, slib_n, slib_p
21
!distribute item $wims_read_parm into slib_m, slib_n, slib_p
-
 
22
!if $slib_p>1 or $slib_p<0
-
 
23
  slib_out=
-
 
24
  !exit
-
 
25
!endif
-
 
26
!if $slib_p=0
-
 
27
  slib_out=!makelist 0 for x=1 to $slib_m
-
 
28
  !exit
-
 
29
!endif
-
 
30
!if $slib_p=1
-
 
31
  slib_out=!makelist $slib_n for x=1 to $slib_m
-
 
32
  !exit
-
 
33
!endif
19
slib_u=!random 0,1 repeat $slib_m
34
slib_u=!random 0,1 repeat $slib_m
20
slib_C=!values x for x=0 to $[$slib_n]
35
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);\
36
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;\
37
  for(k=1,m,u=[$slib_u][k];q=p[1];i=1;\
24
if(u<q,listput(L,x[1]),while(u>=q,i=i+1;q+=p[i]);listput(L,x[i])));L};\
38
  if(u<q,listput(L,x[1]),while(u>=q,i=i+1;q+=p[i]);listput(L,x[i])));L};\
25
{slib_bino(n,p,m)=local(q,b,prob);b=listcreate(n+1);\
39
  {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);\
40
  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));\
41
  for(i=1,n,prob=prob*(n-i+1)/i*q;listput(b,prob));\
28
print(Vec(slib_g(b,[$slib_C],m)))};\
42
  Vec(slib_g(b,[$slib_C],m))};\
29
print(slib_bino($slib_n,$slib_p,$slib_m));
43
  slib_bino($slib_n,$slib_p,$slib_m)
30
 
44
 
31
slib_out =!word 1 to -2 of $slib_out
-
 
32
slib_out=!declosing $slib_out
45
slib_out=!declosing $slib_out
33
slib_out=!trim $slib_out
46
slib_out=!trim $slib_out
34
 
-