summaryrefslogtreecommitdiff
path: root/PBS2/Untitled.ipynb
blob: 4a1f52c4064b6f857d90ac967e57571f5b284579 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "9b604e23-db98-4106-b0c0-74e72625dfd5",
   "metadata": {},
   "source": [
    "# Exercice 1\n",
    "$n>=2, n \\in \\mathbb{N}, X_1, X_2,\\dots, X_n$ des VAR mutuellement indépendantes de loi $\\mathcal{B}(p)$, $p \\in ]0;1[$\n",
    "\n",
    "## 1\n",
    "$$\n",
    "S_n = \\sum_{i=1}^{N}X_i\n",
    "$$\n",
    "$S_n$ suit une loi Binomiale\n",
    "\n",
    "## 2\n",
    "$S_n \\approx \\mathcal{P}(1)$\n",
    "\n",
    "## 3\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "da4ff45a-49e3-4b51-904d-2cdd31a1b2ff",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.7 0.  0.9 0.4 0.8 0.5 0.2 1.  0.7 0.3 0.1 0.3 0.  0.  0.  0.1 0.  0.3\n",
      " 0.8 0.2 0.1 0.9 0.2 0.5 0.3 0.3 0.8 0.4 0.5 1.  0.4 0.3 0.2 0.9 0.4 0.6\n",
      " 0.7 0.7 1.  0.1 0.5 0.4 0.  0.7 0.  0.2 0.3 0.  0.1 0.6]\n",
      "18\n"
     ]
    }
   ],
   "source": [
    "import random\n",
    "import numpy as np\n",
    "\n",
    "n = 50 #int(input(\"nombre essais\"))\n",
    "p = 0.3 #float(input(\"proba succès générique\"))\n",
    "def binom(n, p):\n",
    "    U = np.zeros(n)\n",
    "    for k in range(n):\n",
    "        U[k] = random.randint(0,10) / 10\n",
    "    S = sum([U[i] < p for i in range(n)])\n",
    "    return S"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "f89c7bbe-ad75-4c23-a504-4b9c36df0895",
   "metadata": {},
   "outputs": [],
   "source": [
    "def poiss(l):\n",
    "    n = 1e6\n",
    "    p = l/n\n",
    "    X = Binom(n,p)\n",
    "    return X"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.13.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}