neurotools.stats.tests module

Additional hypothesis-testing routines to supplement scipy.stats and statsmodels.

neurotools.stats.tests.two_tailed_sampled_test(delta)[source]

Directly test whether a population delta is above or below zero more than chance. This is for use with bootstrap/shuffle tests when stronger assumptions may be inaccurate or risk false-positives.

class neurotools.stats.tests.ZTestResult(z, pvalue)[source]

Bases: NamedTuple

z: float

Alias for field number 0

pvalue: float

Alias for field number 1

neurotools.stats.tests.ztest_from_moments(μ1, s1, μ2, s2)[source]

Calculate z-test given moments from two samples.

class neurotools.stats.tests.WeightedTtestResult(t, pvalue, dof, alternative, sem, mu, s)[source]

Bases: NamedTuple

t: float

Alias for field number 0

pvalue: float

Alias for field number 1

dof: float

Alias for field number 2

alternative: str

Alias for field number 3

sem: float

Alias for field number 4

mu: float

Alias for field number 5

s: float

Alias for field number 6

neurotools.stats.tests.weighted_ttest_1samp(x, w, alternative='two-sided')[source]

Test if mean of independent samples x with weights w is different from zero using a to-tailed one-sample t-test.

neurotools.stats.tests.beta_propotion_test(a1, b1, a2, b2, npts=1000, eps=0.5)[source]

(experimental)

Use a Beta distribution model to determine whether two propotions are significantly different.

Parameters:
  • a1 (positive int) – Number of items in category 0, group 1

  • b1 (positive int) – Number of items in category 1, group 1

  • a2 (positive int) – Number of items in category 0, group 2

  • b2 (positive int) – Number of items in category 1, group 2

Returns:

  • mudelta (float) – When positive: The probability of being in the second category is larger for the second group, compared to the first.

  • p (float) – Two-tailed p-value for significant diffierence in rates between the groups.

neurotools.stats.tests.cohen_d(x, y)[source]

Calculate Cohen’s d effect-size summary for independent samples from two unpaired populations.