3

5Y1@s*ddlZddlZddlZGdddZdS)Nc@seZdZddZddZddZddZd	d
ZddZd
dZ	ddZ
ddZddZe
ddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Ze
d3d4Ze
d5d6Zd7S)8	AnalyticscCsd||_|j|_|j|_|j|_|j|_|j	|_
|j|_|j
|_|j|_|j|_dS)N)_Analytics__arraycount_Analytics__countsum_Analytics__sumavg_Analytics__avgmedian_Analytics__medianmode2_Analytics__modemin_Analytics__minmax_Analytics__maxrange_Analytics__rangestdDev_Analytics__stdDev)selfarrayr:/home/s/sultans/web/python/demo/oo/zAnalytics/Analytics.py__init__s







zAnalytics.__init__cCs|jS)N)r)rrrrgetCount"szAnalytics.getCountcCs|jS)N)r)rrrrgetSum#szAnalytics.getSumcCs|jS)N)r	)rrrrgetAvg$szAnalytics.getAvgcCs|jS)N)r)rrrr	getMedian%szAnalytics.getMediancCs|jS)N)r
)rrrrgetMode&szAnalytics.getModecCs|jS)N)r)rrrrgetMin'szAnalytics.getMincCs|jS)N)r)rrrrgetMax(szAnalytics.getMaxcCs|jS)N)r)rrrrgetRange)szAnalytics.getRangecCs|jS)N)r)rrrr	getStdDev*szAnalytics.getStdDevc
Cs:g}x0|D](}yt|}|j|Wq
Yq
Xq
W|S)N)floatappend)rarray2colZnumrrr	normalize/s

zAnalytics.normalizecCs
t|jS)N)lenr)rrrrr?szAnalytics.countcCs
t|jS)N)rr)rrrrr@sz
Analytics.sumcCs
t|jS)N)rr)rrrrrAsz
Analytics.mincCs
t|jS)N)rr)rrrrrBsz
Analytics.maxcCst|jt|jS)N)rrr)rrrrrCszAnalytics.rangecCstj|jS)N)
statisticsZmeanr)rrrrrEsz
Analytics.avgcCstj|jS)N)r*r
r)rrrrr
FszAnalytics.mediancCstj|jS)N)r*Z
median_lowr)rrrrmedianLGszAnalytics.medianLcCstj|jS)N)r*Zmedian_highr)rrrrmedianHHszAnalytics.medianHcCstj|jS)N)r*Zpstdevr)rrrrrJszAnalytics.stdDevcCstj|jS)N)r*Zstdevr)rrrrstdDevSKszAnalytics.stdDevScCstjj}d}d}g}t|j}xH|D]@}||kr:|d7}q$||krJ|}g}||kr\|j|d}|}q$W||krx|}g}||kr|j||S)Nr)sys
float_inforsortedrr%)rZprevColZ	prevCountmaxOccurmodesr&r'rrrmodegs*




zAnalytics.modecCsd}g}i}x8|jD].}y||d7<Wqd||<YqXqWt|jdddd}x,|D]$}|\}}||krxP|j||}qbW|S)Nr.r/cSs|dS)Nr/r)elemrrr<lambda>sz!Analytics.mode2.<locals>.<lambda>T)keyreverse)rr2itemsr%)rr3r4dictr6ZlistOfTuplestupleZoccurrrrrs 

zAnalytics.mode2cCsdt|j}|dt|j7}|dt|j7}|dt|j7}|dt|j7}|dt|j7}|dt|j7}|dt|j7}|d	t|j	7}|d
t|j
7}|S)Nz
Data points: z
Count......: z
Sum........: z
Average....: z
Median.....: z
Mode.......: z
Minimum....: z
Maximum....: z
Range......: z
Std.Dev....: )strrrrr	rr
rrrr)rdatarrr__str__szAnalytics.__str__c	Csjd}g}|dkr||}|dkr8t|}t|}||}|dkrfx$|D]}x|D]}|j|qPWqFW|S)Nrrowr'all)ziplistr%)		array2dimtypeZidxsizerobjr&r@r'rrrslices

zAnalytics.slicecCst|}tt}|S)N)rBrCrG)rDr&rrr	transposeszAnalytics.transposeN)__name__
__module____qualname__rrrrrrr r!r"r#staticmethodr(rrrrrrr
r+r,rr-r5rr?rHrIrrrrr
s6.r)Zmathr*r0rrrrr<module>	s