擅长:python、mysql、java
<pre><code>def CronbachAlpha(itemscores):
itemscores = numpy.asarray(itemscores)
itemvars = itemscores.var(axis=1, ddof=1)
tscores = itemscores.sum(axis=0)
nitems = len(itemscores)
return nitems / (nitems-1.) * (1 - itemvars.sum() / tscores.var(ddof=1))
</code></pre>
<p>NumPy内置了一个方差函数。指定<code>ddof=1</code>使用分母N-1,给出样本方差。还有一个<code>sum</code>内置的。在</p>