Interactive Examples - Try Real Simple Stats Online
Run Real Simple Stats directly in your browser without any installation!
Quick Start Options
Option 1: Google Colab (Recommended)
Advantages:
No setup required
Free GPU access
Save to Google Drive
Share with collaborators
Option 2: Binder
Advantages:
No account needed
Runs in browser
Pre-configured environment
Option 3: Local Jupyter
pip install real-simple-stats jupyter
jupyter notebook
📚 Interactive Notebooks
1. Getting Started Tutorial
File: examples/01_getting_started.ipynb
Topics Covered:
Installation and setup
Basic descriptive statistics
Creating your first analysis
Interpreting results
Launch:
2. Hypothesis Testing Workshop
File: examples/02_hypothesis_testing.ipynb
Topics Covered:
t-tests (one-sample, two-sample, paired)
Chi-square tests
ANOVA
Interpreting p-values
Effect sizes
Launch:
3. Regression Analysis
File: examples/03_regression_analysis.ipynb
Topics Covered:
Simple linear regression
Multiple regression
Model diagnostics
Predictions
Visualization
Launch:
4. Time Series Analysis
File: examples/04_time_series.ipynb
Topics Covered:
Moving averages
Autocorrelation
Trend analysis
Seasonal decomposition
Forecasting basics
Launch:
5. Bayesian Statistics
File: examples/05_bayesian_stats.ipynb
Topics Covered:
Prior and posterior distributions
Conjugate updates
Credible intervals
Bayes factors
Practical applications
Launch:
6. Resampling Methods
File: examples/06_resampling.ipynb
Topics Covered:
Bootstrap confidence intervals
Permutation tests
Jackknife estimation
Cross-validation
When to use each method
Launch:
7. Power Analysis & Study Design
File: examples/07_power_analysis.ipynb
Topics Covered:
Sample size calculations
Power analysis for different tests
Effect size planning
Study design optimization
Launch:
8. Real-World Case Studies
File: examples/08_case_studies.ipynb
Topics Covered:
A/B testing analysis
Survey data analysis
Clinical trial simulation
Quality control
Social science research
Launch:
Quick Examples
Example 1: Basic Statistics
# Run this in Colab or Binder!
!pip install real-simple-stats
import real_simple_stats as rss
# Your data
data = [23, 25, 28, 30, 32, 35, 38, 40, 42, 45]
# Calculate statistics
print(f"Mean: {rss.mean(data):.2f}")
print(f"Median: {rss.median(data)}")
print(f"Std Dev: {rss.sample_std_dev(data):.2f}")
print(f"5-Number Summary: {rss.five_number_summary(data)}")
Example 2: Hypothesis Testing
import real_simple_stats as rss
# Two groups to compare
control = [23, 25, 28, 30, 32]
treatment = [28, 30, 35, 38, 40]
# Perform t-test
t_stat, p_value = rss.two_sample_t_test(control, treatment)
print(f"t-statistic: {t_stat:.3f}")
print(f"p-value: {p_value:.3f}")
# Calculate effect size
d = rss.cohens_d(control, treatment)
interpretation = rss.interpret_effect_size(d, 'd')
print(f"Cohen's d: {d:.3f} ({interpretation})")
Example 3: Regression Analysis
import real_simple_stats as rss
# Data
hours_studied = [1, 2, 3, 4, 5, 6, 7, 8]
test_scores = [55, 60, 65, 70, 75, 80, 85, 90]
# Fit regression
slope, intercept, r_value, p_value, std_err = rss.linear_regression(
hours_studied, test_scores
)
print(f"Equation: y = {slope:.2f}x + {intercept:.2f}")
print(f"R² = {r_value**2:.3f}")
print(f"p-value = {p_value:.4f}")
# Make prediction
predicted_score = rss.regression_equation(10, slope, intercept)
print(f"Predicted score for 10 hours: {predicted_score:.1f}")
Example 4: Bootstrap Confidence Interval
import real_simple_stats as rss
import numpy as np
# Sample data
data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# Bootstrap CI for the mean
result = rss.bootstrap(data, np.mean, n_iterations=1000, confidence_level=0.95)
print(f"Sample mean: {result['statistic']:.2f}")
print(f"95% CI: {result['confidence_interval']}")
print(f"Standard error: {np.std(result['bootstrap_distribution']):.2f}")
Example 5: Power Analysis
import real_simple_stats as rss
# Calculate required sample size
result = rss.power_t_test(
delta=0.5, # Effect size (Cohen's d)
power=0.8, # Desired power
sig_level=0.05 # Significance level
)
print(f"Required sample size per group: {result['n']}")
print(f"Total participants needed: {result['n'] * 2}")
Educational Modules
Module 1: Understanding p-values
Interactive Visualization
import real_simple_stats as rss
import matplotlib.pyplot as plt
import numpy as np
# Simulate null distribution
null_samples = [rss.mean(np.random.normal(0, 1, 30)) for _ in range(1000)]
# Your observed statistic
observed = 0.5
# Calculate p-value
p_value = sum(abs(x) >= abs(observed) for x in null_samples) / len(null_samples)
# Visualize
plt.hist(null_samples, bins=50, alpha=0.7, edgecolor='black')
plt.axvline(observed, color='red', linestyle='--', label=f'Observed ({observed})')
plt.axvline(-observed, color='red', linestyle='--')
plt.title(f'Null Distribution (p-value = {p_value:.3f})')
plt.xlabel('Test Statistic')
plt.ylabel('Frequency')
plt.legend()
plt.show()
Module 2: Effect Size Interpretation
Interactive Calculator
import real_simple_stats as rss
def effect_size_calculator(group1, group2):
"""Interactive effect size calculator"""
# Calculate multiple effect sizes
d = rss.cohens_d(group1, group2)
g = rss.hedges_g(group1, group2)
# Interpret
d_interp = rss.interpret_effect_size(d, 'd')
print("=" * 50)
print("EFFECT SIZE ANALYSIS")
print("=" * 50)
print(f"Cohen's d: {d:.3f} ({d_interp})")
print(f"Hedges' g: {g:.3f}")
print(f"\nGroup 1: M = {rss.mean(group1):.2f}, SD = {rss.sample_std_dev(group1):.2f}")
print(f"Group 2: M = {rss.mean(group2):.2f}, SD = {rss.sample_std_dev(group2):.2f}")
print("=" * 50)
# Try it!
control = [20, 22, 24, 26, 28]
treatment = [25, 28, 30, 32, 35]
effect_size_calculator(control, treatment)
Module 3: Confidence Interval Simulator
Visualize Coverage
import real_simple_stats as rss
import matplotlib.pyplot as plt
import numpy as np
def simulate_confidence_intervals(true_mean=100, true_std=15, n=30,
n_simulations=100, confidence=0.95):
"""Simulate confidence intervals to show coverage"""
covers_true_mean = 0
plt.figure(figsize=(12, 8))
for i in range(n_simulations):
# Generate sample
sample = np.random.normal(true_mean, true_std, n)
# Calculate CI
sample_mean = rss.mean(sample)
sample_std = rss.sample_std_dev(sample)
lower, upper = rss.confidence_interval_unknown_std(
sample_mean, sample_std, n, confidence
)
# Check if CI covers true mean
covers = lower <= true_mean <= upper
covers_true_mean += covers
# Plot
color = 'green' if covers else 'red'
plt.plot([lower, upper], [i, i], color=color, alpha=0.5)
plt.plot(sample_mean, i, 'o', color=color, markersize=3)
# Add true mean line
plt.axvline(true_mean, color='blue', linestyle='--', linewidth=2,
label=f'True Mean ({true_mean})')
coverage = covers_true_mean / n_simulations
plt.title(f'{confidence*100}% Confidence Intervals\n'
f'Coverage: {coverage*100:.1f}% (Expected: {confidence*100}%)')
plt.xlabel('Value')
plt.ylabel('Simulation')
plt.legend()
plt.tight_layout()
plt.show()
print(f"Coverage rate: {coverage*100:.1f}%")
print(f"Expected: {confidence*100}%")
# Run simulation
simulate_confidence_intervals()
🔬 Advanced Interactive Examples
Bayesian Updating Visualization
import real_simple_stats as rss
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats
def visualize_bayesian_update(prior_alpha=1, prior_beta=1,
successes=7, trials=10):
"""Visualize Bayesian updating"""
# Update
post_alpha, post_beta = rss.beta_binomial_update(
prior_alpha, prior_beta, successes, trials
)
# Plot
x = np.linspace(0, 1, 1000)
prior = stats.beta.pdf(x, prior_alpha, prior_beta)
posterior = stats.beta.pdf(x, post_alpha, post_beta)
plt.figure(figsize=(10, 6))
plt.plot(x, prior, label='Prior', linewidth=2)
plt.plot(x, posterior, label='Posterior', linewidth=2)
plt.axvline(successes/trials, color='red', linestyle='--',
label=f'MLE ({successes}/{trials})')
plt.xlabel('Probability')
plt.ylabel('Density')
plt.title(f'Bayesian Update: Beta({prior_alpha}, {prior_beta}) → '
f'Beta({post_alpha}, {post_beta})')
plt.legend()
plt.grid(alpha=0.3)
plt.show()
# Try it!
visualize_bayesian_update(prior_alpha=2, prior_beta=2, successes=7, trials=10)
📱 Mobile-Friendly Options
Google Colab on Mobile
Open Google Colab
Sign in with Google account
File → Open notebook → GitHub
Enter:
kylejones200/real_simple_statsSelect any example notebook
Jupyter Lite (No Installation)
Try Jupyter in your browser: JupyterLite
🎮 Interactive Widgets
Widget Example: Statistical Test Selector
from ipywidgets import interact, widgets
import real_simple_stats as rss
@interact(
test_type=widgets.Dropdown(
options=['One-Sample t-test', 'Two-Sample t-test', 'Paired t-test'],
description='Test:'
),
alpha=widgets.FloatSlider(min=0.01, max=0.10, step=0.01, value=0.05,
description='α:')
)
def run_test(test_type, alpha):
"""Interactive test runner"""
if test_type == 'One-Sample t-test':
data = [23, 25, 28, 30, 32]
mu0 = 30
t_stat, p_value = rss.one_sample_t_test(data, mu0)
print(f"One-Sample t-test (H₀: μ = {mu0})")
elif test_type == 'Two-Sample t-test':
group1 = [23, 25, 28, 30, 32]
group2 = [28, 30, 35, 38, 40]
t_stat, p_value = rss.two_sample_t_test(group1, group2)
print(f"Two-Sample t-test")
elif test_type == 'Paired t-test':
before = [23, 25, 28, 30, 32]
after = [25, 27, 30, 33, 35]
t_stat, p_value = rss.paired_t_test(before, after)
print(f"Paired t-test")
print(f"t-statistic: {t_stat:.3f}")
print(f"p-value: {p_value:.4f}")
print(f"Significance level: {alpha}")
if p_value < alpha:
print(f"Reject H₀ (p < {alpha})")
else:
print(f"✗ Fail to reject H₀ (p ≥ {alpha})")
🌐 Web-Based Demos
Interactive web demos can use Chart.js, Observable, or similar for visualizations. Compute statistics with Real Simple Stats (via Pyodide in the browser, or from a backend) and pass the results to your charting library.
📦 Setup Instructions
For Google Colab
# First cell - install package
!pip install real-simple-stats
# Second cell - import and use
import real_simple_stats as rss
# Your code here
For Binder
No setup needed! Everything is pre-configured.
For Local Jupyter
# Install
pip install real-simple-stats jupyter matplotlib
# Launch
jupyter notebook
# Or use JupyterLab
pip install jupyterlab
jupyter lab
Learning Paths
Path 1: Complete Beginner
Getting Started Tutorial
Hypothesis Testing Workshop
Regression Analysis
Case Studies
Path 2: Intermediate User
Time Series Analysis
Resampling Methods
Power Analysis
Advanced Case Studies
Path 3: Advanced Topics
Bayesian Statistics
Multivariate Analysis
Custom Workflows
Research Applications
Tips for Interactive Learning
Best Practices:
Run all cells from top to bottom first
Modify parameters to see how results change
Try your own data by replacing example datasets
Save your work (File → Save a copy in Drive for Colab)
Share notebooks with collaborators
Common Issues:
Package not found: Run
!pip install real-simple-statsfirstKernel died: Restart kernel and run all cells again
Import errors: Make sure all imports are in the first cell
Additional Resources
Documentation: ReadTheDocs
GitHub: Source Code
PyPI: Package Page
Issues: Report Problems
🤝 Contributing Examples
Want to add your own interactive example?
Fork the repository
Create a new notebook in
examples/Add Colab/Binder badges
Submit a pull request
See CONTRIBUTING.md for details.
Happy Learning!
Try the examples above and explore statistical concepts interactively!