Subversion Repositories wimsdev

Rev

Rev 20 | Rev 4161 | 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
2
 !goto proc
3
!endif
4
slib_title=Geometric mean of data
5
slib_parms=1\
6
 ,[data] or [data],[weight]
7
slib_author=Adeline Grelot
8
slib_out=geometric mean,total weight
9
slib_comment=The numbers must be strictly positive. \
10
 Data and weight can be recognized under many formats, \
11
 in particular as a matrix (with data before weight).
12
slib_example=[3,5,6]\
13
[3,5,6],[4,1,1]\
14
[3,5,6;4,1,1]
3265 bpr 15
slib_require=pari
20 reyssat 16
!exit
17
 
18
:proc
19
!readproc slib/stat/dataproc $wims_read_parm
20
 
21
!if $slib_cnt=0
22
slib_out=1
23
!else
24
!if $slib_weight =$empty
25
slib_data=!product x for x in $slib_data
26
slib_out=$[($slib_data)^(1/$slib_cnt)],$slib_cnt
27
!else
28
slib_out=!exec pari print(prod(x=1,$slib_cnt,[$slib_data][x]^[$slib_weight][x])^(1/$slib_tw))
29
slib_out=$slib_out,$slib_tw
30
 
31
!endif weight
32
!endif
33
slib_out =!trim $slib_out