{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# `doex` - Design and Analysis of Experiments\n", "\n", "\n", "- [GitHub](https://github.com/rohitsanj/doex)\n", "- [PyPI](https://pypi.org/project/doex/)\n", "- [Docs](https://doex.rohitsanjay.com/)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already up-to-date: doex in /Users/rohitsanjay/miniconda3/lib/python3.8/site-packages (0.0.2)\n", "Requirement already satisfied, skipping upgrade: prettytable>=1.0.1 in /Users/rohitsanjay/miniconda3/lib/python3.8/site-packages (from doex) (1.0.1)\n", "Requirement already satisfied, skipping upgrade: scipy>=1.5 in /Users/rohitsanjay/miniconda3/lib/python3.8/site-packages (from doex) (1.5.2)\n", "Requirement already satisfied, skipping upgrade: numpy>=1.19 in /Users/rohitsanjay/miniconda3/lib/python3.8/site-packages (from doex) (1.19.2)\n", "Requirement already satisfied, skipping upgrade: setuptools in /Users/rohitsanjay/miniconda3/lib/python3.8/site-packages (from prettytable>=1.0.1->doex) (49.6.0.post20200814)\n", "Requirement already satisfied, skipping upgrade: wcwidth in /Users/rohitsanjay/miniconda3/lib/python3.8/site-packages (from prettytable>=1.0.1->doex) (0.2.5)\n" ] } ], "source": [ "!pip install doex --upgrade" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Completely Randomized Design" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "+---------------------+-----+----------------+---------------------+-------------+---------+\n", "| Source of Variation | DOF | Sum of Squares | Mean Sum of Squares | F statistic | p value |\n", "+---------------------+-----+----------------+---------------------+-------------+---------+\n", "| Treatments | 2 | 450.6667 | 225.3333 | 7.0356 | 0.0145 |\n", "| Error | 9 | 288.2500 | 32.0278 | | |\n", "| Total | 11 | 738.9167 | | | |\n", "+---------------------+-----+----------------+---------------------+-------------+---------+\n" ] } ], "source": [ "import doex\n", "\n", "exp = doex.CompletelyRandomizedDesign(\n", " [24, 28, 37, 30], # Treatment 1\n", " [37, 44, 31, 35], # Treatment 2\n", " [42, 47, 52, 38], # Treatment 3\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2. One Way ANOVA" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "+---------------------+-----+----------------+---------------------+-------------+---------+\n", "| Source of Variation | DOF | Sum of Squares | Mean Sum of Squares | F statistic | p value |\n", "+---------------------+-----+----------------+---------------------+-------------+---------+\n", "| Treatments | 2 | 450.6667 | 225.3333 | 7.0356 | 0.0145 |\n", "| Error | 9 | 288.2500 | 32.0278 | | |\n", "| Total | 11 | 738.9167 | | | |\n", "+---------------------+-----+----------------+---------------------+-------------+---------+\n" ] } ], "source": [ "import doex\n", "\n", "exp = doex.OneWayANOVA(\n", " [24, 28, 37, 30], # Treatment 1\n", " [37, 44, 31, 35], # Treatment 2\n", " [42, 47, 52, 38], # Treatment 3\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3. Randomized Complete Block Design" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "+---------------------+-----+----------------+---------------------+-------------+---------+\n", "| Source of Variation | DOF | Sum of Squares | Mean Sum of Squares | F statistic | p value |\n", "+---------------------+-----+----------------+---------------------+-------------+---------+\n", "| Treatments | 3 | 12.9500 | 4.3167 | 2.3761 | 0.1211 |\n", "| Blocks | 4 | 157.0000 | 39.2500 | 21.6055 | 0.0000 |\n", "| Error | 12 | 21.8000 | 1.8167 | | |\n", "| Total | 19 | 191.7500 | | | |\n", "+---------------------+-----+----------------+---------------------+-------------+---------+\n" ] } ], "source": [ "import doex\n", "\n", "exp = doex.RandomizedCompleteBlockDesign(\n", " [\n", " [73, 68, 74, 71, 67],\n", " [73, 67, 75, 72, 70],\n", " [75, 68, 78, 73, 68],\n", " [73, 71, 75, 75, 69],\n", " ]\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 4. Two Way ANOVA" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "+---------------------+-----+----------------+---------------------+-------------+---------+\n", "| Source of Variation | DOF | Sum of Squares | Mean Sum of Squares | F statistic | p value |\n", "+---------------------+-----+----------------+---------------------+-------------+---------+\n", "| Treatments | 3 | 0.3850 | 0.1283 | 14.4375 | 0.0009 |\n", "| Blocks | 3 | 0.8250 | 0.2750 | 30.9375 | 0.0000 |\n", "| Error | 9 | 0.0800 | 0.0089 | | |\n", "| Total | 15 | 1.2900 | | | |\n", "+---------------------+-----+----------------+---------------------+-------------+---------+\n" ] } ], "source": [ "import doex\n", "\n", "exp = doex.TwoWayANOVA(\n", " [\n", " [9.3, 9.4, 9.6, 10.0],\n", " [9.4, 9.3, 9.8, 9.9],\n", " [9.2, 9.4, 9.5, 9.7],\n", " [9.7, 9.6, 10.0, 10.2],\n", " ]\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 5. Latin Square Design" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "+---------------------+-----+----------------+---------------------+-------------+---------+\n", "| Source of Variation | DOF | Sum of Squares | Mean Sum of Squares | F statistic | p value |\n", "+---------------------+-----+----------------+---------------------+-------------+---------+\n", "| Treatments | 4 | 141.4400 | 35.3600 | 11.3092 | 0.0005 |\n", "| Rows | 4 | 15.4400 | 3.8600 | 1.2345 | 0.3476 |\n", "| Columns | 4 | 12.2400 | 3.0600 | 0.9787 | 0.4550 |\n", "| Error | 12 | 37.5200 | 3.1267 | | |\n", "| Total | 24 | 206.6400 | | | |\n", "+---------------------+-----+----------------+---------------------+-------------+---------+\n" ] } ], "source": [ "import doex\n", "\n", "exp = doex.LatinSquare(\n", " [\n", " [\"A\", \"B\", \"D\", \"C\", \"E\"],\n", " [\"C\", \"E\", \"A\", \"D\", \"B\"],\n", " [\"B\", \"A\", \"C\", \"E\", \"D\"],\n", " [\"D\", \"C\", \"E\", \"B\", \"A\"],\n", " [\"E\", \"D\", \"B\", \"A\", \"C\"],\n", " ],\n", " [\n", " [8, 7, 1, 7, 3],\n", " [11, 2, 7, 3, 8],\n", " [4, 9, 10, 1, 5],\n", " [6, 8, 6, 6, 10],\n", " [4, 2, 3, 8, 8],\n", " ],\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.5" } }, "nbformat": 4, "nbformat_minor": 4 }