python - Numpy 1 Degree of Freedom -


in following code i'm confused third line means. ddof = 1 do. tried looking up, still don't quite understand concept or purpose. appreciate if point me in right direction.

thanks

data = stats.binom.rvs(n = 10, p = 0.3, size = 10000) print "mean: %g" % np.mean(data) print "sd: %g" % np.std(data, **ddof=1**) 

degrees of freedom important concept may want look up, computational difference straight forward, consider these:

in [20]:  x = np.array([6,5,4,6,6,7,2]) in [21]:  np.std(x) out[21]: 1.5518257844571737  #default ddof=0, does: in [22]:  np.sqrt((((x-x.mean())**2)/len(x)).sum()) out[22]: 1.5518257844571737 in [23]:  np.std(x, ddof=1) out[23]: 1.6761634196950517  #what ddof=1 does: in [24]:  np.sqrt((((x-x.mean())**2)/(len(x)-1)).sum()) out[24]: 1.6761634196950517 

in languages (r, sas etc), default return std of ddof=1. numpy's default ddof=0, worth noting.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -