help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
statsmodels-statistical
/
__pycache__
RSK World
statsmodels-statistical
Statistical Modeling with Statsmodels
__pycache__
  • advanced_time_series.cpython-313.pyc12.4 KB
  • automated_reporting.cpython-313.pyc11.6 KB
  • bayesian_statistics.cpython-313.pyc8.9 KB
  • data_preprocessing.cpython-313.pyc10.9 KB
  • econometric_modeling.cpython-313.pyc12.8 KB
  • hypothesis_testing.cpython-313.pyc14.3 KB
  • model_evaluation.cpython-313.pyc10.7 KB
  • model_persistence.cpython-313.pyc8.3 KB
  • model_selection.cpython-313.pyc12.9 KB
  • panel_data_analysis.cpython-313.pyc9.1 KB
  • performance_benchmarking.cpython-313.pyc9.7 KB
  • regression_analysis.cpython-313.pyc11.8 KB
  • statistical_diagnostics.cpython-313.pyc16.8 KB
  • time_series_analysis.cpython-313.pyc14.4 KB
  • visualization_utils.cpython-313.pyc14.5 KB
03_hypothesis_testing.ipynb
notebooks/03_hypothesis_testing.ipynb
Raw Download
Find: Go to:
{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Hypothesis Testing with Statsmodels\n",
        "\n",
        "<!--\n",
        "Author: RSK World\n",
        "Website: https://rskworld.in\n",
        "Email: help@rskworld.in\n",
        "Phone: +91 93305 39277\n",
        "Description: Statistical hypothesis testing including t-tests, chi-square, ANOVA\n",
        "-->\n",
        "\n",
        "This notebook demonstrates various hypothesis testing methods.\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Load Data from File\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Try to load data from file\n",
        "import os\n",
        "hyp_data_path = os.path.join('..', 'data', 'hypothesis_test_data.csv')\n",
        "if os.path.exists(hyp_data_path):\n",
        "    hyp_df = pd.read_csv(hyp_data_path)\n",
        "    print(\"Loaded Hypothesis Test Data:\")\n",
        "    print(hyp_df.head())\n",
        "    print(f\"\\nData Shape: {hyp_df.shape}\")\n",
        "    \n",
        "    # Extract groups\n",
        "    groups = hyp_df['group'].unique()\n",
        "    sample_dict = {group: hyp_df[hyp_df['group'] == group]['value'].values \n",
        "                   for group in groups}\n",
        "    print(f\"\\nGroups: {groups}\")\n",
        "    print(f\"Sample sizes: {[len(sample_dict[g]) for g in groups]}\")\n",
        "else:\n",
        "    print(\"Data file not found. Using generated data.\")\n",
        "    # Generate sample data\n",
        "    np.random.seed(42)\n",
        "    sample1 = np.random.normal(100, 15, 30)\n",
        "    sample2 = np.random.normal(105, 15, 30)\n",
        "    sample_dict = {'Group 1': sample1, 'Group 2': sample2}\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Comprehensive Hypothesis Tests\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Extract samples for testing\n",
        "if 'sample_dict' in locals():\n",
        "    samples = list(sample_dict.values())\n",
        "    sample1 = samples[0] if len(samples) > 0 else np.random.normal(100, 15, 30)\n",
        "    sample2 = samples[1] if len(samples) > 1 else np.random.normal(105, 15, 30)\n",
        "    sample3 = samples[2] if len(samples) > 2 else np.random.normal(110, 15, 30)\n",
        "else:\n",
        "    sample1 = np.random.normal(100, 15, 30)\n",
        "    sample2 = np.random.normal(105, 15, 30)\n",
        "    sample3 = np.random.normal(110, 15, 30)\n",
        "\n",
        "tests = StatisticalTests()\n",
        "\n",
        "# T-test\n",
        "print(\"T-Test:\")\n",
        "print(\"=\" * 70)\n",
        "tests.t_test(sample1, sample2)\n",
        "\n",
        "# ANOVA\n",
        "print(\"\\n\" + \"=\" * 70)\n",
        "print(\"ANOVA Test:\")\n",
        "print(\"=\" * 70)\n",
        "tests.anova_test({\n",
        "    'Group 1': sample1,\n",
        "    'Group 2': sample2,\n",
        "    'Group 3': sample3\n",
        "})\n",
        "\n",
        "# Normality test\n",
        "print(\"\\n\" + \"=\" * 70)\n",
        "print(\"Normality Test:\")\n",
        "print(\"=\" * 70)\n",
        "tests.normality_test(sample1)\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Import libraries\n",
        "import numpy as np\n",
        "import sys\n",
        "import os\n",
        "\n",
        "sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))\n",
        "from hypothesis_testing import StatisticalTests\n",
        "\n",
        "# Generate sample data\n",
        "np.random.seed(42)\n",
        "sample1 = np.random.normal(100, 15, 30)\n",
        "sample2 = np.random.normal(105, 15, 30)\n",
        "\n",
        "tests = StatisticalTests()\n",
        "tests.t_test(sample1, sample2)\n",
        "tests.normality_test(sample1)\n"
      ]
    }
  ],
  "metadata": {
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 2
}
138 lines•4.3 KB
json

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer