3

hNa)@sddlZddlZddlZddZddZddZdd	Zd
dZdd
ZddZ	ddZ
ddZddZddZ
ddZddZddZdS)Nc
Cs:g}x0|D](}yt|}|j|Wq
Yq
Xq
W|S)N)floatappend)arrayarray2colZnumr6/home/s/sultans/web/python/demo/analytics/Analytics.py	normalizes

r	cCst|S)N)len)rrrrcountsrcCst|t|S)N)maxmin)rrrrrange#srcCs
tj|S)N)
statisticsZmean)rrrravg%srcCs
tj|S)N)rmedian)rrrrr&srcCs
tj|S)N)rZ
median_low)rrrrmedianL'srcCs
tj|S)N)rZmedian_high)rrrrmedianH(srcCs
tj|S)N)rZpstdev)rrrrstdDev*srcCs
tj|S)N)rZstdev)rrrrstdDevS+srcCstjj}d}d}g}t|}xH|D]@}||kr8|d7}q"||krH|}g}||krZ|j|d}|}q"W||krv|}g}||kr|j||S)Nr)sys
float_infor
sortedr)rZprevColZ	prevCountmaxOccurmodesrrrrrmodeDs*



rcCsd}g}i}x6|D].}y||d7<Wqd||<YqXqWt|jdddd}x,|D]$}|\}}||krvP|j||}q`W|S)NrrcSs|dS)Nrr)elemrrr<lambda>pszmode2.<locals>.<lambda>T)keyreverse)ritemsr)rrrdictrZlistOfTuplestupleZoccurrrrmode2ds 


r%cCsdt|}|dtt|7}|dtt|7}|dtt|7}|dtt|7}|dtt|7}|dtt|7}|dtt|7}|d	tt|7}|d
tt	|7}|S)Nz
Data points: z
Count......: z
Sum........: z
Average....: z
Median.....: z
Mode.......: z
Minimum....: z
Maximum....: z
Range......: z
Std.Dev....: )
strrsumrrrr
rrr)rdatarrrtoStringsr)c	Csjd}g}|dkr||}|dkr8t|}t|}||}|dkrfx$|D]}x|D]}|j|qPWqFW|S)Nrrowrall)ziplistr)		array2dimtypeZidxsizerobjrr*rrrrslices

r2cCst|}t|}|S)N)r,r-)r.r1rrrr	transposesr3)Zmathrrr	rrrrrrrrrr%r)r2r3rrrr<module>	s  3