Determining if data in a txt file obeys certain statistics
Question: I'm working with a Geiger counter which can be hooked up to a computer and
which records its output in the form of a .txt file, NC.txt, where it records
the time since starting and the 'value' of the radiation it recorded. It looks
like

    
    
    import pylab
    import scipy.stats
    import numpy as np
    import matplotlib.pyplot as plt
    x1 = []
    y1 = []
    #Define a dictionary: counts
    f = open("NC.txt", "r")
    for line in f:
       line = line.strip()
       parts = line.split(",") #the columns are separated by commas and spaces
       time = float(parts[1])  #time is recorded in the second column of NC.txt
       value = float(parts[2]) #and the value it records is in the third
       x1.append(time)
       y1.append(value)
    f.close()
    
    xv = np.array(x1)
    yv = np.array(y1)
    
    #Statistics
    m = np.mean(yv)
    d = np.std(yv)
    #Strip out background radiation
    trueval = yv - m
    
    #Basic plot of counts
    num_bins = 10000
    plt.hist(trueval,num_bins)
    plt.xlabel('Value')
    plt.ylabel('Count')
    plt.show()
    

So this code so far will just create a simple histogram of the radiation
counts centred at zero, so the background radiation is ignored.

What I want to do now is perform a chi-squared test to see how well the data
fits, say, Poisson statistics (and then go on to compare it with other
distributions later). I'm not really sure how to do that. I have access to
scipy and numpy, so I feel like this should be a simple task, but just
learning python as I go here, so I'm not a terrific programmer.

Does anyone know of a straightforward way to do this?

Edit for clarity: I'm not asking so much about if there is a chi-squared
function or not. I'm more interested in how to compare it with other
statistical distributions.

Thanks in advance.


Answer: You can use SciPy library, [here is
documentation](http://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.stats.chisquare.html)
and examples.

