Subversion Repositories wimsdev

Rev

Rev 3129 | Go to most recent revision | Details | 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=Effectifs of statistical series in classes
5
slib_parms=2\
6
 ,[x_1,...,x_n] \
7
 ,[a_1,...,a_m]
8
slib_author=Adeline Grelot et Bernadette PERRIN-RIOU
9
slib_out= [effectifs of classes] ,[classes data]
10
slib_comment= data : [x_1,...,x_n]  ; classes : [a_1,...,a_m] (with min and max add if necessary) ;\
11
 if only 2 numbers in classes data, first one is the smaller, second one the width of classes ;\
12
 if no classes, classes are created of width ceil(4*n^(1/4)
13
slib_example=[1,1,1,3,4,5,6,2],[1,4,6]\
14
[1,1,1,3,4,5,6,2,7 ,4,7],[2,3,6]\
15
[1,1,1,3,4,5,6,2],[1,4]\
16
[1,1,1,3,4,5,6,2]
17
 
18
!exit
19
:proc
20
slib_out=
21
 
22
!readproc slib/stat/dataproc $wims_read_parm
23
 
24
slib_v=!declosing $slib_data
25
slib_w=!declosing $slib_weight
26
!if $slib_v$slib_w=$empty
27
	slib_out=0
28
	!exit
29
!else
30
	slib_v=!sort numeric item  of $slib_v
31
	slib_max=!item -1 of $slib_v
32
	slib_min=!item 1 of $slib_v
33
	slib_cnt= !itemcnt $slib_v
34
	slib_cntw=!itemcnt $slib_w
35
	!if $slib_cntw=2
36
		!distribute item $slib_w into slib_b,slib_p
37
		slib_c=$[ceil(($slib_max-$slib_b)/$slib_p)]
38
		slib_d=$[min(0,floor(($slib_min-($slib_b))/$slib_p))]
39
		slib_w=!values $slib_b+x*$slib_p for x=$slib_d to $slib_c
40
	!endif
41
	slib_w=!sort numeric item  of $slib_w
42
	!if $slib_w=$empty
43
		slib_N=$[ceil(4*($slib_cnt)^(1/4))]
44
		slib_w=!values $slib_min+x*$[(($slib_max-($slib_min))/$slib_N)] for x=0 to $slib_N
45
	!else
46
		slib_m=!item -1 of $slib_w
47
		slib_max=$[max($slib_max,$slib_m)]
48
		slib_m=!item 1 of $slib_w
49
		slib_min=$[min($slib_min,$slib_m)]
50
		slib_w=$slib_min,$slib_w,$slib_max
51
		slib_w= !listuniq $slib_w
52
	!endif
53
	slib_cpt=0
54
	slib_cntw=!itemcnt $slib_w
55
	slib_wpointer=2
56
# end est le point de separation
57
	slib_end=!item $slib_wpointer of $slib_w
58
	slib_result=
59
	!for slib_i=1 to $slib_cnt
60
 		slib_dat=!item $slib_i of $slib_v
61
		!if $slib_dat<$slib_end or ($slib_dat=$slib_max and $slib_wpointer=$slib_cntw)
62
  # On est toujours dans le meme intervalle
63
 			!advance slib_cpt
64
 		!else
65
  # Le point de separation franchi
66
  # creer un nouveau point de separation
67
:point
68
 			!advance slib_wpointer
69
 			 slib_end=!item $slib_wpointer of $slib_w
70
 			!if $slib_wpointer < $slib_cntw
71
 				slib_end1=!item $[$slib_wpointer+1] of $slib_w
72
			!else 
73
				slib_end1=$slib_end+2
74
			!endif
75
		slib_result=!append item $[$slib_cpt] to $slib_result
76
			!if $slib_dat>=$slib_end1
77
				slib_cpt=0
78
				!goto point
79
			!else
80
				slib_cpt=1
81
			!endif
82
		!endif
83
	!next slib_i
84
#Le dernier intervalle
85
	slib_result=!append item $[$slib_cpt] to $slib_result
86
	!if $[$slib_wpointer+1] <=$slib_cntw
87
		slib_zero=!values 0 for x=$[$slib_wpointer+1] to $slib_cntw
88
		slib_result=$slib_result,$slib_zero
89
	!endif
90
!endif
91
slib_out=!trim $slib_result
92
slib_out=!line -1 of $slib_out
93
slib_out=[$slib_out],[$slib_w]