Appendix 1 - choH (python version)

13. Appendix 1 - choH (python version)#

import scipy
import numpy
import matplotlib.pyplot as plt
from math import log
def choH(data) :
    test = lambda i : log(scipy.stats.kstest(data[-i:],data[:-i]).pvalue)
    return [float(x) for x in list(map(test,range(1,len(data))))]
numpy.random.seed(0)
X = [float(x) for x in list(numpy.random.normal(0,1,1000)) + list(numpy.random.normal(0.3,1,1000))]
plt.plot(X)
plt.plot(choH(X))
[<matplotlib.lines.Line2D at 0x74f96ce4a5a0>]
_images/76194f2ef1c24f9594a232b1d0fb8f28d84f315abc0b874e2c3c820340b6564d.png