statistics — Mathematical statistics functions — Python 3.9.6 ... | Python statistics package

Navigationindexmodules|next|previous|Python»3.9.6Documentation»ThePythonStandardLibrary»NumericandMathematicalModules»|statistics—Mathematicalstatisticsfunctions¶Newinversion3.4.Sourcecode:Lib/statistics.pyThismoduleprovidesfunctionsforcalculatingmathematicalstatisticsofnumeric(Real-valued)data.Themoduleisnotintendedtobeacompetitortothird-partylibrariessuchasNumPy,SciPy,orproprietaryfull-featuredstatisticspackagesaimedatprofessionalstatisticianssuchasMinitab,SASandMatlab.Itisaimedatthelevelofgraphingandscientificcalculators.Unlessexplicitlynoted,thesefunctionssupportint,float,DecimalandFraction.Behaviourwithothertypes(whetherinthenumerictowerornot)iscurrentlyunsupported.Collectionswithamixoftypesarealsoundefinedandimplementation-dependent.Ifyourinputdataconsistsofmixedtypes,youmaybeabletousemap()toensureaconsistentresult,forexample:map(float,input_data).Averagesandmeasuresofcentrallocation¶Thesefunctionscalculateanaverageortypicalvaluefromapopulationorsample.mean()Arithmeticmean(“average”)ofdata.fmean()Fast,floatingpointarithmeticmean.geometric_mean()Geometricmeanofdata.harmonic_mean()Harmonicmeanofdata.median()Median(middlevalue)ofdata.median_low()Lowmedianofdata.median_high()Highmedianofdata.median_grouped()Median,or50thpercentile,ofgroupeddata.mode()Singlemode(mostcommonvalue)ofdiscreteornominaldata.multimode()Listofmodes(mostcommonvalues)ofdiscreteornomimaldata.quantiles()Dividedataintointervalswithequalprobability.Measuresofspread¶Thesefunctionscalculateameasureofhowmuchthepopulationorsampletendstodeviatefromthetypicaloraveragevalues.pstdev()Populationstandarddeviationofdata.pvariance()Populationvarianceofdata.stdev()Samplestandarddeviationofdata.variance()Samplevarianceofdata.Functiondetails¶Note:Thefunctionsdonotrequirethedatagiventothemtobesorted.However,forreadingconvenience,mostoftheexamplesshowsortedsequences.statistics.mean(data)¶Returnthesamplearithmeticmeanofdatawhichcanbeasequenceoriterable.Thearithmeticmeanisthesumofthedatadividedbythenumberofdatapoi


常見投資理財問答


延伸文章資訊