{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "#"
      ],
      "id": "19dedbfa-65a6-425b-b7a9-f81806640fda"
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {},
      "outputs": [],
      "source": [
        "import numpy as np"
      ],
      "id": "76fe1ed5-3396-4c33-92b4-011dd3bcff35"
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {},
      "outputs": [],
      "source": [
        "class BernoulliDistribution():\n",
        "    def __init__(self, p = 0.5):\n",
        "        self._p = p\n",
        "    def mean(self):\n",
        "        return self._p\n",
        "    def var(self):\n",
        "        p = self._p\n",
        "        return p * (1 - p)\n",
        "    def std(self):\n",
        "        return np.sqrt(self.var())"
      ],
      "id": "8008994b-6292-4094-9e42-238805e54af0"
    },
    {
      "cell_type": "code",
      "execution_count": 3,
      "metadata": {},
      "outputs": [],
      "source": [
        "B1 = BernoulliDistribution() # (p = 0.5)"
      ],
      "id": "74f9d8bc-0725-4885-a1e2-1c578ff2e136"
    },
    {
      "cell_type": "code",
      "execution_count": 4,
      "metadata": {},
      "outputs": [
        {
          "output_type": "display_data",
          "metadata": {},
          "data": {
            "text/plain": [
              "0.5"
            ]
          }
        }
      ],
      "source": [
        "B1.mean()"
      ],
      "id": "ac95cf4f-5487-43d2-992a-ac51a729c4c8"
    },
    {
      "cell_type": "code",
      "execution_count": 5,
      "metadata": {},
      "outputs": [
        {
          "output_type": "display_data",
          "metadata": {},
          "data": {
            "text/plain": [
              "0.77"
            ]
          }
        }
      ],
      "source": [
        "B2 = BernoulliDistribution(p = 0.77)\n",
        "B2.mean()"
      ],
      "id": "d21a898a-bb7f-4ee4-b12f-ac4005d50c7f"
    }
  ],
  "nbformat": 4,
  "nbformat_minor": 5,
  "metadata": {
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3 (ipykernel)",
      "language": "python"
    },
    "language_info": {
      "name": "python",
      "codemirror_mode": {
        "name": "ipython",
        "version": "3"
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.12.12"
    }
  }
}