Subversion Repositories wimsdev

Rev

Rev 8775 | 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
4
 
4161 bpr 5
 
20 reyssat 6
slib_parms=3\
7
,m\
8
0,mu\
9
1,sigma
10
 
4330 bpr 11
slib_author=Adeline, Grelot; Bernadette, PERRIN-RIOU
4161 bpr 12
 
4482 bpr 13
slib_example=5,0,2
20 reyssat 14
!exit
15
 
16
:proc
17
!distribute item $wims_read_parm into  slib_m,slib_mu,slib_sigma
18
!default slib_mu=0
19
!default slib_sigma=1
20
 
8775 bpr 21
slib_m2= $[floor(($slib_m)/2)]
20 reyssat 22
slib_U1=!random 10^-20,1 repeat $[$slib_m2+1]
23
slib_U2=!random 0,1 repeat $[$slib_m2+1]
24
 
25
slib_w=!values sqrt(-2*log(x)) for x in $slib_U1
26
slib_w1=!values cos(2*Pi*x) for x in $slib_U2
27
slib_w2=!values sin(2*Pi*x) for x in $slib_U2
28
 
29
slib_V=$empty
30
!for slib_i=1 to $[$slib_m2 +1]
13586 bpr 31
  slib_v=!item  $slib_i of $slib_w
32
  slib_v1=!item  $slib_i of $slib_w1
33
  slib_v2=!item  $slib_i of $slib_w2
34
  slib_v1=$[$slib_sigma*$slib_v1*$slib_v+$slib_mu]
35
  slib_v2=$[$slib_sigma*$slib_v2*$slib_v+$slib_mu]
20 reyssat 36
 
13586 bpr 37
  !if  $slib_i<=$slib_m2
38
    slib_V=!append item $slib_v1 to $slib_V
39
    slib_V=!append item $slib_v2 to $slib_V
40
  !endif
41
  !if $slib_i>$slib_m2 and   $[2*$slib_m2]!=$slib_m
42
    slib_V=!append item $slib_v1 to $slib_V
43
  !endif
20 reyssat 44
!next slib_i
45
 
7692 bpr 46
!if $slib_m >1
13586 bpr 47
  slib_V=!shuffle $slib_V
20 reyssat 48
!endif
49
 
50
slib_out=!trim $slib_V