Statistical analysis libraries

Doing the path's calculations in Python: scipy.stats (quantiles, t.interval, t-tests, chi-squared), statsmodels for a proportion's interval, pandas for the contingency table; the R equivalents are named.

  • 22 cards
  • 5 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Questions
  3. Sort and link
  4. Scenarios
  5. Understand

A few cards from the deck

  • scipy.stats: what is it?

    Show the answer

    A Python scientific computing module that provides probability distributions (norm, t, chi2) and statistical tests (ttest_1samp, ttest_ind, ttest_rel, chisquare, chi2_contingency).

    Each distribution offers ppf (quantile), cdf (cumulative probability) and sf (tail). Each test returns the statistic and the p-value.

  • What does this program print?

    ```python
    from scipy import stats
    print(round(stats.norm.ppf(0.975), 2))
    `

    • 1.96
    • 1.64
    • 0.98
    • 2.58
    Show the answer

    1.96

    ppf(0.975) leaves 2.5% of the normal distribution on the right: it is the quantile of the two-sided 95% interval. 1.64 is ppf(0.95) and 2.58 is ppf(0.995).

  • In R, the function … runs the t-tests, … the chi-squared test and … tests a proportion.

    Show the answer

    In R, the function t.test runs the t-tests, chisq.test the chi-squared test and prop.test tests a proportion.

    t.test(x, y, paired = TRUE) corresponds to scipy's ttest_rel. R gathers under one name what scipy splits into several functions.

  • statsmodels: what is it?

    Show the answer

    A Python statistical analysis library, offering among other things the confidence interval of a proportion with proportion_confint.

    proportion_confint(successes, total, alpha=0.05, method='normal') returns both bounds. The method option picks the formula, 'normal' being the one in the course.

  • The same 30 pages are measured before and after an optimisation, and the script runs stats.ttest_ind(before, after). Which fix is right?

    • stats.ttest_1samp(before, after)
    • stats.chisquare(before, after)
    • stats.ttest_rel(before, after), paired series
    • stats.ttest_ind(before, after, equal_var=False)
    Show the answer

    stats.ttest_rel(before, after), paired series

    ttest_rel tests page-by-page differences. equal_var=False fixes another problem (unequal variances between two distinct groups). ttest_1samp expects a value, not a second series.