{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import seaborn\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "1回の試行で14試合5口分の予想が前回購入のものと一致する確率は\n", "\n", "$ p = \\left( \\frac{1}{3} \\right) ^{70} $" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "$N$ 回試行したときに1度も上記事象が発生しない確率\n", "\n", "$ q = \\left( 1 - p \\right) ^N $" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "$ q $ の対数を取る\n", "\n", "$ \\log{q} = N \\log \\left( 1 - p \\right) $" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "1次近似すると\n", "\n", "$ \\log{q} \\sim -N \\left( \\frac{1}{3} \\right) ^{70} $" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "def prob(k):\n", " lq = - 1.0 / np.power(3.0, 70 - k)\n", " q = np.exp(lq)\n", " return q" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "def probs(ks):\n", " lab = []\n", " val = []\n", " for k in ks:\n", " lab.append(k)\n", " val.append(prob(k))\n", " df = pd.DataFrame({'q': val})\n", " df.index = lab\n", " return df" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "$ N = 3 ^k $ 回試行したときの確率の概算値" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
q
501.000000
551.000000
600.999983
650.995893
700.367879
\n", "
" ], "text/plain": [ " q\n", "50 1.000000\n", "55 1.000000\n", "60 0.999983\n", "65 0.995893\n", "70 0.367879" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "probs([50, 55, 60, 65, 70])" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "1回の抽選で400万口程度売れるらしいので、1回の抽選で $ 3 ^{12} $ 以上の試行がある" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "800000.0\n", "531441.0\n" ] } ], "source": [ "print(4000000 / 5)\n", "print(np.power(3.0, 12))" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "0.5%で当該事象の起こるくらいに必要な抽選回数" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "6.4610818892266729e+24" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.power(3.0, 65 - 12 - 1)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "誕生日のパラドックスのような状況になるには、試行1回当りの発生確率が小さすぎるようだ" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "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.6.0" } }, "nbformat": 4, "nbformat_minor": 2 }