/usr/lib/python3/dist-packages/csb/test/cases/statistics/__init__.py is in python3-csb 1.2.2+dfsg-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | import numpy
import numpy.random
import csb.test as test
from csb.statistics import Cumulative
from csb.statistics import kurtosis, skewness, autocorrelation
@test.functional
class TestStatFunction(test.Case):
def testCumulative(self):
from scipy.stats import norm
x = numpy.linspace(-5., 5., 200)
samples = numpy.random.normal(size=100000)
cumula = Cumulative(samples)
c = cumula(x)
cx = norm.cdf(x)
for i in range(199):
self.assertAlmostEqual(cx[i], c[i], delta=1e-2)
def testKurtosis(self):
samples = numpy.random.normal(size=100000)
self.assertAlmostEqual(kurtosis(samples), 0., delta=1e-1)
samples = numpy.random.uniform(-2., 2., size=100000)
self.assertAlmostEqual(kurtosis(samples), -1.2, delta=1e-1)
def testSkewness(self):
samples = numpy.random.gamma(2., 0.5, size=100000)
self.assertAlmostEqual(skewness(samples), 2. / numpy.sqrt(2.), delta=1e-1)
def testAutorcorrelation(self):
x = numpy.random.normal(size=1000) + numpy.sin(numpy.linspace(0., 2 * numpy.pi, 1000))
n = 10
ac = autocorrelation(x, n)
self.assertAlmostEqual(ac[0], 1., delta=1e-1)
def testEntropy(self):
pass
def testCircvar(self):
pass
def testCircmean(self):
pass
|