{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "GvGbrH13EDCE",
        "outputId": "69028cdc-1bf8-4cbc-e661-aae1522efa8a"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "t统计量: -3.4379234697901877\n",
            "P值: 0.00885084939309251**\n"
          ]
        }
      ],
      "source": [
        "import numpy as np\n",
        "from scipy import stats\n",
        "\n",
        "# Example data for two independent samples (mean, std dev, sample size)\n",
        "mean1 = 102.2072\n",
        "std1 = 18.089\n",
        "nobs1 = 5\n",
        "\n",
        "mean2 = 133.8234\n",
        "std2 = 9.78\n",
        "nobs2 = 5\n",
        "\n",
        "# Perform independent samples t-test using stats\n",
        "t_stat, p_value = stats.ttest_ind_from_stats(mean1=mean1, std1=std1, nobs1=nobs1,\n",
        "                                              mean2=mean2, std2=std2, nobs2=nobs2)\n",
        "\n",
        "# Determine significance stars\n",
        "stars = ''\n",
        "if p_value < 0.001:\n",
        "    stars = '***'\n",
        "elif p_value < 0.01:\n",
        "    stars = '**'\n",
        "elif p_value < 0.05:\n",
        "    stars = '*'\n",
        "\n",
        "print(f\"t统计量: {t_stat}\")\n",
        "print(f\"P值: {p_value}{stars}\")"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
