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