expyfun.analyze.rt_chisq

expyfun.analyze.rt_chisq(x, axis=None, warn=True)[source]

Chi square fit for reaction times (a better summary statistic than mean)

Parameters:
xarray-like

Reaction time data to fit.

axisint | None

The axis along which to calculate the chi-square fit. If none, x will be flattened before fitting.

warnbool

If True, warn about possible bad reaction times.

Returns:
peakfloat | array-like

The peak(s) of the fitted chi-square probability density function(s).

Notes

Verify that it worked by plotting pdf vs hist (for 1-dimensional x):

>>> import numpy as np
>>> from scipy import stats as ss
>>> import matplotlib.pyplot as plt
>>> rng = np.random.RandomState(0)
>>> x = np.abs(rng.randn(10000) + 1)
>>> lsp = np.linspace(np.floor(np.min(x)), np.ceil(np.max(x)), 100)
>>> df, loc, scale = ss.chi2.fit(x, floc=0)
>>> pdf = ss.chi2.pdf(lsp, df, scale=scale)
>>> plt.plot(lsp, pdf)   
[<matplotlib.lines.Line2D object at ...>]
>>> _ = plt.hist(x, density=True)