diff --git a/notebook/problems.ipynb b/notebook/problems.ipynb index ff2c594b..6561e545 100644 --- a/notebook/problems.ipynb +++ b/notebook/problems.ipynb @@ -30,12 +30,87 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 11, "id": "34720ab6", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Normal Distribution:\n", + "Mean: -0.028619142236640034\n", + "Median: -0.017270072330735627\n", + "Mode: ModeResult(mode=-1.789772257755604, count=1)\n", + "Standard Deviation: 0.8504782461047726\n", + "Variance: 0.7233132470974502\n", + "Range: 4.1504060137771885\n", + "Kurtosis: -0.22984275091294082\n", + "Skewness: 0.1876392566353732\n", + "Chi-Square Distribution (degrees of freedom = 3):\n", + "Mean: 3.0351302359457906\n", + "Median: 2.396361773406997\n", + "Mode: ModeResult(mode=0.0826946028144708, count=1)\n", + "Standard Deviation: 2.3641911718270654\n", + "Varaince: 5.589399896945032\n", + "Range: 12.234950149104789\n", + "Kurtosis: 2.078076991312349\n", + "Skewness: 1.3992822141563568\n" + ] + } + ], "source": [ - "# TODO" + "# TODO\n", + "import numpy as np\n", + "from scipy.stats import kurtosis, skew, mode\n", + "\n", + "np.random.seed(88)\n", + "\n", + "normal_distribution = np.random.normal(0, 1, 100)\n", + "chi_square_distribution = np.random.chisquare(3, 100)\n", + "\n", + "# normal metrics\n", + "normal_mean = np.mean(normal_distribution)\n", + "normal_median = np.median(normal_distribution)\n", + "normal_mode = mode(normal_distribution)\n", + "normal_std = np.std(normal_distribution)\n", + "normal_variance = np.var(normal_distribution)\n", + "normal_range = np.amax(normal_distribution) - np.amin(normal_distribution)\n", + "normal_kurtosis = kurtosis(normal_distribution)\n", + "normal_skewness = skew(normal_distribution)\n", + "\n", + "\n", + "# chi metrics\n", + "chi_mean = np.mean(chi_square_distribution)\n", + "chi_median = np.median(chi_square_distribution)\n", + "chi_mode = mode(chi_square_distribution)\n", + "chi_std = np.std(chi_square_distribution)\n", + "chi_variance = np.var(chi_square_distribution)\n", + "chi_range = np.amax(chi_square_distribution) - np.amin(chi_square_distribution)\n", + "chi_kurtosis = kurtosis(chi_square_distribution)\n", + "chi_skewness = skew(chi_square_distribution)\n", + "\n", + "\n", + "# results\n", + "print(\"Normal Distribution:\")\n", + "print(\"Mean:\", normal_mean)\n", + "print(\"Median:\", normal_median)\n", + "print(\"Mode:\", normal_mode)\n", + "print(\"Standard Deviation:\", normal_std)\n", + "print(\"Variance:\", normal_variance)\n", + "print(\"Range:\", normal_range)\n", + "print(\"Kurtosis:\", normal_kurtosis)\n", + "print(\"Skewness:\", normal_skewness)\n", + "\n", + "print(\"Chi-Square Distribution (degrees of freedom = 3):\")\n", + "print(\"Mean:\", chi_mean)\n", + "print(\"Median:\", chi_median)\n", + "print(\"Mode:\", chi_mode)\n", + "print(\"Standard Deviation:\", chi_std)\n", + "print(\"Varaince:\", chi_variance)\n", + "print(\"Range:\", chi_range)\n", + "print(\"Kurtosis:\", chi_kurtosis)\n", + "print(\"Skewness:\", chi_skewness)\n" ] }, { @@ -54,12 +129,37 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "id": "d590308e", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Standard Deviation: 2.0\n" + ] + } + ], "source": [ - "# TODO" + "# TODO\n", + "\n", + "data = [4, 2, 5, 8, 6]\n", + "\n", + "def calc_mean(data):\n", + " return sum(data) / len(data)\n", + "\n", + "def calc_std_dev(data):\n", + " mean = calc_mean(data)\n", + " variance = sum((x - mean) ** 2 for x in data) / len(data)\n", + " std_dev = variance ** 0.5\n", + " return std_dev\n", + "\n", + "\n", + "standard_deviation = calc_std_dev(data)\n", + "\n", + "\n", + "print(\"Standard Deviation:\", standard_deviation)" ] } ],