diff options
| -rw-r--r-- | IAML/Modèles.md | 18 | ||||
| -rw-r--r-- | ICQ/CM1.md (renamed from IQC/CM1.md) | 0 | ||||
| -rw-r--r-- | ICQ/CM2.md (renamed from IQC/CM2.md) | 0 | ||||
| -rw-r--r-- | ICQ/CM3.md | 152 | ||||
| -rw-r--r-- | IQC/CM3.md | 15 | ||||
| -rw-r--r-- | PBS1/Stats.md | 18 | ||||
| -rw-r--r-- | PVCM/cama/fr/ma54 Gradient pour résoudre Ax = b -- Exercice.ipynb | 161 | ||||
| -rw-r--r-- | Pasted image 20250612153013.png | bin | 0 -> 920624 bytes |
8 files changed, 302 insertions, 62 deletions
diff --git a/IAML/Modèles.md b/IAML/Modèles.md new file mode 100644 index 0000000..98e177e --- /dev/null +++ b/IAML/Modèles.md @@ -0,0 +1,18 @@ +# Regression linéaire +-> Trouver les paramètres d'une fonction pour qu'elle colle aux données +# Erreur d'estimation +# Apprentissage supervisé +## Hypothèses +- Il existe une fonction cible, **f** : _observations -> étiquette +- Cependant, cette fonction est inconnue +- On dispose d'un nombre d'observations et d'étiquettes associées +## But +Trouver une fonction $h$ qui approxime $f$ étant donné notre ensemble d'apprentissage +## Différence avec l'apprentissage humain +- On n'utilise aucun connaissance existante à priori +- On dispose d'accès limité au données +- On pose des hypothèses sur la forme de $f$ +# Généralité de l'approche +Ajout de termes de régularisation + +# Arbres de décision diff --git a/ICQ/CM3.md b/ICQ/CM3.md new file mode 100644 index 0000000..a742fb2 --- /dev/null +++ b/ICQ/CM3.md @@ -0,0 +1,152 @@ +# Représentations matricielles +Il existe un isomorphisme entre l'espace de Hilbert associé à un qubit et l'espace des matrices $M_{2}(\mathbb{C})$. +- Par définition : + - $\ket{0} = \begin{pmatrix}1 \\ 0\end{pmatrix}$ + - $\ket{1} = \begin{pmatrix}0 \\ 1\end{pmatrix}$ +On a $\ket{\psi} = c_{1}\ket{0} + c_{2}\ket{1}$ pour tout $\ket{\psi}$ représentant un qubit ($c_i \in \mathbb{C}$) +- De plus $$ +\begin{align} +\bra{\psi} &= c_{1}^*(1 \quad 0) + c_{2}^*(0 \quad 1) \\ +&= (c_{1}^* \quad c_{2}^*) \\ +&= c_{1}^*\bra{0} + c_{2}^*\bra{1} +\end{align} +$$ +- $\ketbra{\psi}{\phi} = \begin{pmatrix}c_{1} \\ c_{2}\end{pmatrix} \cdot \begin{pmatrix}d_{1}^* & d_{2}^*\end{pmatrix} = \begin{pmatrix}c_{1}d_{1}^* & c_{1}d_{2}^* \\ c_{2}d_{1}^* & c_{2}d_{2}^*\end{pmatrix}$ +- $\braket{ \phi | \psi } = (d_{1}^* \quad d_{2}^*) \cdot \begin{pmatrix}c_{1} \\ c_{2}\end{pmatrix} = d_{1}^*c_{1} + d_{2}^*c_{2}$ +# Représentation de Bloch +L'état d'un qubit correspond également à un point sur la sphère unité +Si $\ket{\phi} = \begin{pmatrix}c_{1} \\ c_{2}\end{pmatrix}$ alors on a +$$ +\begin{align} +c_{1} = x_{0} + ix_{1} \\ +c_{2} = x_{2} + ix_{3} +\end{align} +$$ +où $|c_{1}|^2 + |c_{2}|^2 = 1$ +On peut effectuer le changement de variable : +$$ +\begin{align} +x_{0} &= \cos(\frac{\theta}{2})\cdot\cos(\beta) \\ +x_{1} &= \cos(\frac{\theta}{2})\cdot\sin(\beta) \\ +x_{2} &= \sin(\frac{\theta}{2})\cdot\cos(\beta + \phi) \\ +x_{3} &= \sin(\frac{\theta}{2})\cdot\sin(\beta + \phi) +\end{align} +$$ +On obtient alors : +$$ +\ket{\phi} = e^{i\beta} \cdot \begin{pmatrix} +\cos (\frac{\theta}{2}) \\ +e^{i\phi}\cdot \sin(\frac{\theta}{2}) +\end{pmatrix} +$$ +où $\beta$ est une phase (complexe) sans signification physique : $\braket{ \phi | \phi }$ ne dépend pas de $\beta$ + +L'état $\ket{\phi}$ peut donc être associé à un point sur la sphère unité avec les coordonnées $(x,y,z) = (\sin \theta \cdot \cos \phi,\sin \theta \cdot \sin \phi, \cos \theta)$ + +# Matrices de Pauli +On peut représenter un état dans une base différente de $\{ \ket{0}, \ket{1} \}$ +On peut utiliser la base $\{ \ket{u}, \ket{v} \}$ tels que : +$$ +\begin{align} +\ket{u} &= \frac{\ket{0} + \ket{1}}{\sqrt{ 2 } } \\ +\ket{v} &= \frac{\ket{0} - \ket{1} }{\sqrt{ 2 }} +\end{align} +$$ +De manière similaire si +$$ +\begin{align} +M &= 0 \cdot \ketbra{0}{0} + 1 \cdot \ketbra{1}{1} \\ +&= \begin{pmatrix} +0 & 0 \\ +0 & 1 +\end{pmatrix} +\end{align} +$$ +et dans la base $\{ \ket{u}, \ket{v} \}$ ou peut construire +$$ +\begin{align} +\ketbra{u}{u} - \ketbra{v}{v} &= \sigma_{x} \\ +&= X +\end{align} +$$ +Où $X$ est la _1ère matrice de Pauli_ +Les matrices $\sigma_{x}, \sigma_{y}, \sigma_{z}$ forment une base pour les matrices $M(\mathbb{C}_{2\times 2})$ +Elles vérifient la relation de commutation +$$ +\begin{align} +[\sigma_{i},\sigma_{j}] &= \sigma_{i}\sigma_{j} - \sigma_{j}\sigma_{i} \\ +&= 2 i \cdot \sum_{k} \epsilon_{ijk} \cdot \sigma_{k} +\end{align} +$$ +où $\epsilon_{ijk}$ est le symbole de Levi-Civita tq +$$ +\epsilon_{ijk} = \begin{cases} ++1 \qquad \text{si } (ijk) \text{ est une permutation paire de (123) : (1,2,3) ou (2,3,1) ou (3,1,2)} \\ +-1 \qquad \text{si } \dots \text{ impaire : (3,2,1),(1,3,2) ou (2,1,3)} \\ +0 \qquad \text{si i = j ou j = k ou k = i} +\end{cases} +$$ + +#### Exemple : +$$ +\begin{align} +&[\sigma_{x},\sigma_{y}] = 2i\sigma_{z} \\ +&\text{avec } i = x, j = y, k = z +\end{align} +$$ + +Cette relation est à la base de la structure d'algèbre de Lic où les $\sigma_{i}$ sont les générateurs des transformations unitaires + +# Polarisation de la lumière (??) +- Une onde électro-magnétique (EM) se propageant selon une direction $z$ est caractérisée par son champ $\vec{E}$ qui est $\bot$ à $z$ +- Le champ $\vec{E}$ peut s'écrire : +$$ +\vec{E} = E_{0}\cdot e^{i\delta_{0}} (\cos \theta \vec{i} + e^{i\delta}\sin \theta \vec{i}) e^{i\omega t} +$$ +- où $E_{0}$ est l'amplitude au champ $\vec{E}$ +- La partie réelle correspond à un champ "tournant" à une fréquence $\omega$ +- Pour simplifier l'expression de $\vec{E}$, on peut utiliser le vecteur de Jones $\vec{J} = \begin{pmatrix}\cos \theta \\ e^{i\delta} \sin \theta\end{pmatrix}$ +- La direction de $\vec{E}$ pour une onde EM définit sa **polarisation** (donnée par le vecteur de Jones) +- Par exemple, si $\delta = 0 = \theta$ alors $\vec{J} = \begin{pmatrix}1 \\ 0\end{pmatrix}= \ket{0}$ +- et si $\theta = \frac{\pi}{2}, \, \delta = 0$ alors $\vec{J} = \begin{pmatrix}0 \\ 1\end{pmatrix} = \ket{1}$ +- Si l'onde (ou photon) est dans : + - l'état $\ket{0}$, la polarisation est dans l'état $H$ (parfois noté $\ket{H}$ ou $\ket{h}$) + - l'état $\ket{1}$, la polarisation est dans l'état $V$, (noté $\ket{V}$ ou $\ket{v}$) + +Dans ce type de polarisation rectiligne, $\vec{E}$ rest dans un plan contenant son ax de propagation et il oscille entre $-E_{0}$ et $+E_{0}$ (figure 2 p12) + +D'autres polarisations sont possibles : +Les états propres de $\sigma_{y}$ ($\frac{1}{\sqrt{ 2 }} \begin{pmatrix}1 \\ i\end{pmatrix}, \frac{1}{\sqrt{ 2 }}\begin{pmatrix}1 \\ -i\end{pmatrix}$) forment une base qui permet de décrire la polarisation circulaire d'une onde EM vers la gauche ou la droite +L'intérêt technique est qu'on peut modifier la polarisation d'une onde EM par un système de filtres (ou polarisateurs (voir figure 2)) + +Chaque polarisateur peut être associé à un opérateur hermitien s'exprimant comme une combinaison linéaire de matrices de Pauli +Par exemple, l'opérateur $P = \ketbra{R}{R}$ a les vecteurs propres $\ket{R}$ et $\ket{L}$ de valeurs propres respectives $1$ et $0$. +Dans la base $\{ \ket{R}, \ket{L} \}$ on a $P = \begin{pmatrix}1 & 0 \\ 0 & 0\end{pmatrix}$ +Aussi : $\ketbra{L}{L} = \begin{pmatrix}0&0 \\ 0&1\end{pmatrix}$ dans la base $\{ \ket{R}, \ket{L} \}$ +En pratique, ces opérateurs permettent de mesurer si la polarisation d'une onde EM est selon $\ket{R}$ ou non +En termes de matrice de Pauli, on peut déterminer que : +$$ +P = \ketbra{R}{R} = I_{2} + \sigma_{y} +$$ +# Le spin +-> grandeur purement quantique +Expérience de Stern-Gerlach qui montre qu'un faisceau d'$e^-$ est dévié selon $O_z$ quand soumis à un champ magnétique (fig 3) +Chacune des 2 trajectoires ($\pm z$) est associée à un état de **spin** représenté par $\ket{0}$ et $\ket{1}$. La mesure de l'un ou l'autre de ces "états propres" de l'opérateur de spin $S_{z} = \frac{\hbar}{2} \sigma_{z}$ dont les résultats possibles sont $\pm \frac{\hbar}{2}$ + +Si on mesure le spin dans la direction de $x$, on utilise : $S_{x} = \frac{\hbar}{2} \sigma_{x}$ dont la base propre est $\ket{u} = \frac{\ket{0} + \ket{1}}{\sqrt{ 2 }}, \ket{v} = \frac{\ket{0} - \ket{1}}{\sqrt{ 2 }}$ + +## Mesure du spin dans une direction arbitraire +On utilise la combinaison linéaire $n_{x}S_{x} + n_{y} S_{y} + n_{z}S_{z} = \vec{n}\cdot \vec{S}$ avec $||\vec{n}|| = 1$ et $\vec{S} = S_{x}\vec{i} + S_{y}\vec{j} + S_{z}\vec{z}$ + +Pour la règle de Born, si un $e^-$ est dans l'état $\ket{u}$ et que l'on mesure son spin se lon $O_{z}$, on a $S_{0}\%$ de chances de le trouver dans l'état $\ket{0}$ ou $\ket{1}$ +En multipliant les mesures sur l'état $\ket{u}$ du spin selon $O_{z}$, on obtient la valeur moyenne $\braket{ S_{z} } = \bra{u}S_{z}\ket{u}$ +Par le calcul : +$$ +\begin{align} +\braket{ S_{z} } &= \sum_{i}x_{i}p_{i} \\ +&= \frac{1}{2} \cdot \frac{\hbar}{2} + \frac{1}{2} \cdot \left( -\frac{\hbar}{2} \right) \\ +&= 0 \\ +&= \bra{u} \frac{\hbar}{2}\sigma_{z}\ket{u} +\end{align} +$$ +avec $\bra{u} = \frac{\bra{0} + \bra{1}}{\sqrt{ 2 }}$ et $\ket{u} = \frac{\ket{0} + \ket{1}}{\sqrt{ 2 }}$ diff --git a/IQC/CM3.md b/IQC/CM3.md deleted file mode 100644 index 21ce91e..0000000 --- a/IQC/CM3.md +++ /dev/null @@ -1,15 +0,0 @@ -# Représentations matricielles -Il existe un isomorphisme entre l'espace de Hilbert associé à un qubit et l'espace des matrices $M_{2}(\mathbb{C})$. -- Par définition : - - $\ket{0} = \begin{pmatrix}1 \\ 0\end{pmatrix}$ - - $\ket{1} = \begin{pmatrix}0 \\ 1\end{pmatrix}$ -On a $\ket{\psi} = c_{1}\ket{0} + c_{2}\ket{1}$ pour tout $\ket{\psi}$ représentant un qubit ($c_i \in \mathbb{C}$) -- De plus $$ -\begin{align} -\bra{\psi} &= c_{1}^*(1 \quad 0) + c_{2}^*(0 \quad 1) \\ -&= (c_{1}^* \quad c_{2}^*) \\ -&= c_{1}^*\bra{0} + c_{2}^*\bra{1} -\end{align} -$$ -- $\ketbra{\psi}{\phi} = \begin{pmatrix}c_{1} \\ c_{2}\end{pmatrix} = \begin{pmatrix}c_{1}d_{1}^* & c_{1}d_{2}^* \\ c_{2}d_{1}^* & c_{2}d_{2}^*\end{pmatrix}$ -- $\braket{ \phi | \psi } = (d_{1}^* \quad d_{2}^*) \cdot \begin{pmatrix}c_{1} \\ c_{2}\end{pmatrix} = d_{1}^*c_{1} + d_{2}^*c_{2}$ diff --git a/PBS1/Stats.md b/PBS1/Stats.md new file mode 100644 index 0000000..9090482 --- /dev/null +++ b/PBS1/Stats.md @@ -0,0 +1,18 @@ +On dispose d'un jeu de données : $n$ observations de variables $X$, $Y$, etc. +On veut estimer espérances et variances +# Estimation +**Estimateur** d'un paramètre $k$ : variable aléatoire dont le but est d'estimer au mieux d'un paramètre $k$ +On dit que l'estimateur $Z_n$ est un estimateur sans biais du paramètre $k$ si $\mathbb{E}(Z_n) = k$ + +**Echantillon** : Ensemble de VA iid $(X_1,X_2,...,X_n)$ suivant la loi d'une VA $X$. +**Réalisation** : un tableau de valeurs d'un échantillon +$$ +m = \frac{\sum^{N}_{i = 1}X_{i}}{N} +$$ +# Quantile +Pour tout $x \in ]0,1[$ on appelle **Quantile** d'ordre $x$ de la loi $\mathcal{N}(0,1)$ et on note $u_x$ l'unique réel tel que $\phi(u_x) = x$, où $\phi$ désigne la fonction de répartition de la loi $\mathcal{N}(0,1)$. +Si $Z \rightsquigarrow \mathcal{N}(0,1)$ alors pour tout $\alpha \in ]0,1[$, +$$ +P(-u_{1 - \frac{\alpha}{2}} \leq Z \leq U_{1 - \frac{\alpha}{2} }) = 1 - \alpha +$$ +Exemple : la médiane -> t pour lequel $F(t) =0,5 \implies t = F^{-1}(0,5)$ diff --git a/PVCM/cama/fr/ma54 Gradient pour résoudre Ax = b -- Exercice.ipynb b/PVCM/cama/fr/ma54 Gradient pour résoudre Ax = b -- Exercice.ipynb index 2a7cf27..46ec5a8 100644 --- a/PVCM/cama/fr/ma54 Gradient pour résoudre Ax = b -- Exercice.ipynb +++ b/PVCM/cama/fr/ma54 Gradient pour résoudre Ax = b -- Exercice.ipynb @@ -1,25 +1,4 @@ { - "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.10.12" - } - }, - "nbformat": 4, - "nbformat_minor": 4, "cells": [ { "cell_type": "markdown", @@ -41,27 +20,17 @@ }, { "cell_type": "code", - "execution_count": 33, - "metadata": {}, - "outputs": [], - "source": [ - "def solve_with_gradiant(A, b):\n", - " mu = 0.01\n" - ] - }, - { - "cell_type": "code", - "execution_count": 34, + "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([[49, 13],\n", - " [13, 13]])" + "array([[0.15, 0.15],\n", + " [0.15, 0.55]])" ] }, - "execution_count": 34, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -71,21 +40,22 @@ "A = np.random.randint(10, size=(2,2))\n", "A = A + A.T\n", "A += np.diag(A.sum(axis=1))\n", + "A = A / np.sum(np.abs(A))\n", "A" ] }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([62, 26])" + "array([0.3, 0.7])" ] }, - "execution_count": 35, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -97,10 +67,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "metadata": {}, "outputs": [], "source": [ + "def solve_with_gradiant(A, b):\n", + " mu = 0.01\n", + " xi = np.array(np.zeros(b.shape))\n", + " while True:\n", + " xn = xi - mu * (A @ xi - b)\n", + " if np.square(xn - xi).sum() < 1e-6 ** 2:\n", + " break\n", + " xi = xn\n", + " return xi" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([0.9990519 , 1.00031603])" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ "solve_with_gradiant(A,b)" ] }, @@ -117,10 +115,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 39, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "array([0.9990519 , 1.00031603])" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def solve_with_gradiant_inertie(A, b):\n", + " mu = 0.01\n", + " i = 0.5\n", + " xi = np.array(np.zeros(b.shape))\n", + " while True:\n", + " xn = xi - mu * (A @ xi - b)\n", + " if np.square(xn - xi).sum() < 1e-6 ** 2:\n", + " break\n", + " xi = xn\n", + " return xi\n", + "solve_with_gradiant_inertie(A, b)" + ] }, { "cell_type": "markdown", @@ -173,10 +194,56 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 40, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "array([0.99999941, 0.99999941])" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def solve_with_gradiant_inertie_opti(A, b):\n", + " mu = 0.01\n", + " i = 0.5\n", + " xi = np.array(np.zeros(b.shape))\n", + " while True:\n", + " J = A @ xi - b\n", + " mu = np.dot(J, J) / np.dot(A @ J, J)\n", + " xn = xi - mu * (A @ xi - b)\n", + " if np.square(xn - xi).sum() < 1e-6 ** 2:\n", + " break\n", + " xi = xn\n", + " return xi\n", + "solve_with_gradiant_inertie_opti(A,b)" + ] } - ] -}
\ No newline at end of file + ], + "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.13.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/Pasted image 20250612153013.png b/Pasted image 20250612153013.png Binary files differnew file mode 100644 index 0000000..4ab487f --- /dev/null +++ b/Pasted image 20250612153013.png |
