├── README.md └── 01_Probabilidade_e_Estatística_para_Investimentos_com_Python.ipynb /README.md: -------------------------------------------------------------------------------- 1 | # probabilidade_para_investimentos 2 | Estatística e Probabilidade para Investimentos com Python 3 | -------------------------------------------------------------------------------- /01_Probabilidade_e_Estatística_para_Investimentos_com_Python.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "kernelspec": { 6 | "display_name": "Python 3", 7 | "language": "python", 8 | "name": "python3" 9 | }, 10 | "language_info": { 11 | "codemirror_mode": { 12 | "name": "ipython", 13 | "version": 3 14 | }, 15 | "file_extension": ".py", 16 | "mimetype": "text/x-python", 17 | "name": "python", 18 | "nbconvert_exporter": "python", 19 | "pygments_lexer": "ipython3", 20 | "version": "3.6.2" 21 | }, 22 | "colab": { 23 | "name": "01 - Probabilidade e Estatística para Investimentos com Python", 24 | "provenance": [], 25 | "include_colab_link": true 26 | } 27 | }, 28 | "cells": [ 29 | { 30 | "cell_type": "markdown", 31 | "metadata": { 32 | "id": "view-in-github", 33 | "colab_type": "text" 34 | }, 35 | "source": [ 36 | "\"Open" 37 | ] 38 | }, 39 | { 40 | "cell_type": "markdown", 41 | "metadata": { 42 | "id": "sv3bOY-o-6_b", 43 | "colab_type": "text" 44 | }, 45 | "source": [ 46 | "# Probabilidade e Estatística para Investimentos com Python - Simulando um jogo de dados" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "metadata": { 52 | "id": "qaOfcbWO-6_V", 53 | "colab_type": "code", 54 | "colab": {} 55 | }, 56 | "source": [ 57 | "import pandas as pd" 58 | ], 59 | "execution_count": null, 60 | "outputs": [] 61 | }, 62 | { 63 | "cell_type": "markdown", 64 | "metadata": { 65 | "id": "Wfv7lvV3-6_U", 66 | "colab_type": "text" 67 | }, 68 | "source": [ 69 | "## Jogando dois dados e somando os valores das faces" 70 | ] 71 | }, 72 | { 73 | "cell_type": "markdown", 74 | "metadata": { 75 | "id": "QHoRW2Bs_w_v", 76 | "colab_type": "text" 77 | }, 78 | "source": [ 79 | "![alt text](https://media2.giphy.com/media/3ohhwLh5dw0i7iLzOg/giphy.gif?cid=ecf05e47vz5bhal67azfltz9b5dfwcaih4wxyjn4r6frh9u4&rid=giphy.gif)" 80 | ] 81 | }, 82 | { 83 | "cell_type": "markdown", 84 | "metadata": { 85 | "id": "OrqRJPJOG0HC", 86 | "colab_type": "text" 87 | }, 88 | "source": [ 89 | "## Criando os Dados" 90 | ] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "metadata": { 95 | "id": "z_YFitWb-6_c", 96 | "colab_type": "code", 97 | "colab": { 98 | "base_uri": "https://localhost:8080/", 99 | "height": 233 100 | }, 101 | "outputId": "6f55de1a-7f0d-408f-d7c7-f5ab4ebdac4f" 102 | }, 103 | "source": [ 104 | "dado = pd.DataFrame([1,2,3,4,5,6], columns=['face'])\n", 105 | "dado" 106 | ], 107 | "execution_count": null, 108 | "outputs": [ 109 | { 110 | "output_type": "execute_result", 111 | "data": { 112 | "text/html": [ 113 | "
\n", 114 | "\n", 127 | "\n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | "
face
01
12
23
34
45
56
\n", 161 | "
" 162 | ], 163 | "text/plain": [ 164 | " face\n", 165 | "0 1\n", 166 | "1 2\n", 167 | "2 3\n", 168 | "3 4\n", 169 | "4 5\n", 170 | "5 6" 171 | ] 172 | }, 173 | "metadata": { 174 | "tags": [] 175 | }, 176 | "execution_count": 2 177 | } 178 | ] 179 | }, 180 | { 181 | "cell_type": "markdown", 182 | "metadata": { 183 | "id": "myRuxiIpK3C3", 184 | "colab_type": "text" 185 | }, 186 | "source": [ 187 | "## Jogando os Dados" 188 | ] 189 | }, 190 | { 191 | "cell_type": "code", 192 | "metadata": { 193 | "id": "uRxwqLKMG5zf", 194 | "colab_type": "code", 195 | "colab": { 196 | "base_uri": "https://localhost:8080/", 197 | "height": 35 198 | }, 199 | "outputId": "83615cd4-139f-4a3f-f961-78a50e7d8193" 200 | }, 201 | "source": [ 202 | "dado.sample(2, replace=True).sum()['face']" 203 | ], 204 | "execution_count": null, 205 | "outputs": [ 206 | { 207 | "output_type": "execute_result", 208 | "data": { 209 | "text/plain": [ 210 | "6" 211 | ] 212 | }, 213 | "metadata": { 214 | "tags": [] 215 | }, 216 | "execution_count": 11 217 | } 218 | ] 219 | }, 220 | { 221 | "cell_type": "markdown", 222 | "metadata": { 223 | "id": "yJx2Qtzh-6_t", 224 | "colab_type": "text" 225 | }, 226 | "source": [ 227 | "### Jogando várias vezes" 228 | ] 229 | }, 230 | { 231 | "cell_type": "code", 232 | "metadata": { 233 | "id": "jshDm4ly-6_u", 234 | "colab_type": "code", 235 | "colab": {} 236 | }, 237 | "source": [ 238 | "jogadas = 10\n", 239 | "resultados = [ dado.sample(2, replace=True).sum()['face'] for i in range(jogadas) ]" 240 | ], 241 | "execution_count": null, 242 | "outputs": [] 243 | }, 244 | { 245 | "cell_type": "code", 246 | "metadata": { 247 | "id": "BjSO3Viu-6_x", 248 | "colab_type": "code", 249 | "colab": { 250 | "base_uri": "https://localhost:8080/", 251 | "height": 35 252 | }, 253 | "outputId": "a9d518fd-5d08-4ae1-aaf8-670716f509b8" 254 | }, 255 | "source": [ 256 | "print(resultados)" 257 | ], 258 | "execution_count": null, 259 | "outputs": [ 260 | { 261 | "output_type": "stream", 262 | "text": [ 263 | "[7, 4, 5, 7, 7, 10, 5, 11, 5, 7]\n" 264 | ], 265 | "name": "stdout" 266 | } 267 | ] 268 | }, 269 | { 270 | "cell_type": "markdown", 271 | "metadata": { 272 | "id": "CpA8Xu3EyFCL", 273 | "colab_type": "text" 274 | }, 275 | "source": [ 276 | "## Conceitos de Estatística e Probabilidade" 277 | ] 278 | }, 279 | { 280 | "cell_type": "markdown", 281 | "metadata": { 282 | "id": "_GC5mMKn2Xg4", 283 | "colab_type": "text" 284 | }, 285 | "source": [ 286 | "### Experimento Aleatório" 287 | ] 288 | }, 289 | { 290 | "cell_type": "markdown", 291 | "metadata": { 292 | "id": "byMTb7rL2_6v", 293 | "colab_type": "text" 294 | }, 295 | "source": [ 296 | "Características:\n", 297 | "\n", 298 | "1. Pode ser repetido indefinidamente sob condições essencialmente inalteradas\n", 299 | "2. Não podemos afirmar qual resultado particular irá ocorrer mas podemos descrever o conjunto de todos os possíveis resultados\n", 300 | "3. O resultado individual parece ocorrer de forma acidental. Contudo, se for repetido um grande número de vezes uma regularidade começa a ocorrer" 301 | ] 302 | }, 303 | { 304 | "cell_type": "markdown", 305 | "metadata": { 306 | "id": "rTPXmkUm2Xjg", 307 | "colab_type": "text" 308 | }, 309 | "source": [ 310 | "### Espaço Amostral" 311 | ] 312 | }, 313 | { 314 | "cell_type": "markdown", 315 | "metadata": { 316 | "id": "-N_TEnDH7y79", 317 | "colab_type": "text" 318 | }, 319 | "source": [ 320 | "É o conjunto de todos os resultados possíveis de nosso experimento aleatório" 321 | ] 322 | }, 323 | { 324 | "cell_type": "markdown", 325 | "metadata": { 326 | "id": "xNEbSAYZ8iv2", 327 | "colab_type": "text" 328 | }, 329 | "source": [ 330 | "Em nosso jogo de dados o espaço amostral $S$ será:" 331 | ] 332 | }, 333 | { 334 | "cell_type": "markdown", 335 | "metadata": { 336 | "id": "cMpkKYhP9TA1", 337 | "colab_type": "text" 338 | }, 339 | "source": [ 340 | "$S:$ {todos os resultados possíveis ao se somar as faces de dois dados numerados de 1 a 6 }" 341 | ] 342 | }, 343 | { 344 | "cell_type": "markdown", 345 | "metadata": { 346 | "id": "ambqjhPXyPgQ", 347 | "colab_type": "text" 348 | }, 349 | "source": [ 350 | "$S: \\{ 2,3,4,5,6,7,8,9,10,11,12 \\}$\n" 351 | ] 352 | } 353 | ] 354 | } --------------------------------------------------------------------------------