| 
7 | 7 |  "worksheets": [  | 
8 | 8 |   {  | 
9 | 9 |    "cells": [  | 
 | 10 | +    {  | 
 | 11 | +     "cell_type": "markdown",  | 
 | 12 | +     "metadata": {},  | 
 | 13 | +     "source": [  | 
 | 14 | +      "<script src=\"http://d3js.org/d3.v3.min.js\" charset=\"utf-8\"></script>\n"  | 
 | 15 | +     ]  | 
 | 16 | +    },  | 
10 | 17 |     {  | 
11 | 18 |      "cell_type": "markdown",  | 
12 | 19 |      "metadata": {},  | 
 | 
714 | 721 |      ],  | 
715 | 722 |      "prompt_number": 25  | 
716 | 723 |     },  | 
 | 724 | +    {  | 
 | 725 | +     "cell_type": "code",  | 
 | 726 | +     "collapsed": false,  | 
 | 727 | +     "input": [  | 
 | 728 | +      "from IPython.core.display import HTML\n",  | 
 | 729 | +      "\n",  | 
 | 730 | +      "#try executing the below command twice if the first time doesn't work\n",  | 
 | 731 | +      "HTML(filename = \"BanditsD3.html\" )"  | 
 | 732 | +     ],  | 
 | 733 | +     "language": "python",  | 
 | 734 | +     "metadata": {},  | 
 | 735 | +     "outputs": [  | 
 | 736 | +      {  | 
 | 737 | +       "html": [  | 
 | 738 | +        "\n",  | 
 | 739 | +        "    <script src=\"http://d3js.org/d3.v3.min.js\" charset=\"utf-8\"></script>\n",  | 
 | 740 | +        "    <style type=\"text/css\">\n",  | 
 | 741 | +        "\n",  | 
 | 742 | +        "   .bar{\n",  | 
 | 743 | +        "      font: 12px sans-serif;\n",  | 
 | 744 | +        "      text-align: right;\n",  | 
 | 745 | +        "      padding: 3px;\n",  | 
 | 746 | +        "      margin: 1px;\n",  | 
 | 747 | +        "      color: white;\n",  | 
 | 748 | +        "    }\n",  | 
 | 749 | +        "    \n",  | 
 | 750 | +        "    path {\n",  | 
 | 751 | +        "        stroke-width: 3;\n",  | 
 | 752 | +        "        fill: none;\n",  | 
 | 753 | +        "    }\n",  | 
 | 754 | +        "     \n",  | 
 | 755 | +        "    line {\n",  | 
 | 756 | +        "        stroke: black;\n",  | 
 | 757 | +        "    }\n",  | 
 | 758 | +        "     \n",  | 
 | 759 | +        "    text {\n",  | 
 | 760 | +        "        font-family: Computer Modern, Arial;\n",  | 
 | 761 | +        "        font-size: 11pt;\n",  | 
 | 762 | +        "    }\n",  | 
 | 763 | +        "    \n",  | 
 | 764 | +        "    button{\n",  | 
 | 765 | +        "        margin: 6px;\n",  | 
 | 766 | +        "        width:70px;\n",  | 
 | 767 | +        "\n",  | 
 | 768 | +        "        }\n",  | 
 | 769 | +        "    button:hover{\n",  | 
 | 770 | +        "        cursor: pointer;\n",  | 
 | 771 | +        "\n",  | 
 | 772 | +        "        }\n",  | 
 | 773 | +        "\n",  | 
 | 774 | +        "  </style>\n",  | 
 | 775 | +        "\n",  | 
 | 776 | +        "  <div id=\"bb_content\" style=\"width:710px\" >\n",  | 
 | 777 | +        "    <div style=\"margin:20 auto; float: right\">\n",  | 
 | 778 | +        "        <button  \n",  | 
 | 779 | +        "            style=\"width:100px;\"\n",  | 
 | 780 | +        "            onClick = 'bayesian_bandits()' >Run Bayesian Bandits </button>\n",  | 
 | 781 | +        "        <br/>\n",  | 
 | 782 | +        "        <button id=\"buttonReveal\" \n",  | 
 | 783 | +        "            style=\"width:100px;\"\n",  | 
 | 784 | +        "            onClick = 'd3.select(\"#reveal-div\").style(\"display\", \"block\" )' >Reveal probabilities </button>\n",  | 
 | 785 | +        "    </div>\n",  | 
 | 786 | +        "   \n",  | 
 | 787 | +        "    \n",  | 
 | 788 | +        "    <div id = \"paired-bar-chart\"  style=\"width: 400px; margin: 20px\" > </div>\n",  | 
 | 789 | +        "    \n",  | 
 | 790 | +        "\n",  | 
 | 791 | +        "    \n",  | 
 | 792 | +        "    \n",  | 
 | 793 | +        "    <div id=\"scoreboard\" style=\"margin:20px auto; float: right\">\n",  | 
 | 794 | +        "    \n",  | 
 | 795 | +        "        <div style=\"float:left;margin: 20px\"> \n",  | 
 | 796 | +        "            <p style=\"margin: 0px;\"> Rewards </p>\n",  | 
 | 797 | +        "            <p  style=\"font-size:30pt; margin: 0px;\" id=\"rewards\"> 0 </p>\n",  | 
 | 798 | +        "       </div>\n",  | 
 | 799 | +        "\n",  | 
 | 800 | +        "        <div style=\"float:left; margin: 20px\"> \n",  | 
 | 801 | +        "            <p style=\"margin: 0px;\"> Pulls </p>\n",  | 
 | 802 | +        "            <p id=\"pulls\" style=\"margin: 0px;font-size:30pt\"> 0 </p>\n",  | 
 | 803 | +        "        </div>    \n",  | 
 | 804 | +        "        \n",  | 
 | 805 | +        "        <div style=\"margin: 20px\"> \n",  | 
 | 806 | +        "            <p style=\"margin: 0px;\"> Reward/Pull Ratio </p>\n",  | 
 | 807 | +        "            <p id=\"ratio\" style=\"margin: 0px;font-size:30pt\"> 0 </p>\n",  | 
 | 808 | +        "        </div>\n",  | 
 | 809 | +        "        \n",  | 
 | 810 | +        "    \n",  | 
 | 811 | +        "    </div>\n",  | 
 | 812 | +        "    <div id =\"beta-graphs\"  style=\"width: 400px; margin-left:35px;\" > </div>\n",  | 
 | 813 | +        "\n",  | 
 | 814 | +        "    \n",  | 
 | 815 | +        "    <div id=\"buttons\" style=\"margin:20px auto; width: 300px;\">\n",  | 
 | 816 | +        "        <button id=\"button1\" onClick = \"update_arm(0)\"> Arm 1</button>\n",  | 
 | 817 | +        "        <button id=\"button2\" onClick = \"update_arm(1)\"> Arm 2</button>\n",  | 
 | 818 | +        "        <button id=\"button3\" onClick = \"update_arm(2)\"> Arm 3</button>\n",  | 
 | 819 | +        "    </div>  \n",  | 
 | 820 | +        "    \n",  | 
 | 821 | +        "    <div id=\"reveal-div\" style=\"margin:20px auto; width: 300px; display:none\"></div>\n",  | 
 | 822 | +        "    \n",  | 
 | 823 | +        "\n",  | 
 | 824 | +        "\n",  | 
 | 825 | +        "    <p style=\"margin: 20px auto; width:550px\" >\n",  | 
 | 826 | +        "\n",  | 
 | 827 | +        "       Deviations of the observed ratio from the highest probability is a measure of performance. For example, \n",  | 
 | 828 | +        "       in the long run, optimally we can attain the reward/pull ratio of the maximum bandit probability. \n",  | 
 | 829 | +        "       Long-term realized ratios <em>less</em> than the maximum represent inefficiencies. (Realized ratios <em>larger<em> \n",  | 
 | 830 | +        "       than the maximum probability is \n",  | 
 | 831 | +        "       due to randomness, and will eventually fall below). \n",  | 
 | 832 | +        "    </p>\n",  | 
 | 833 | +        "    \n",  | 
 | 834 | +        "  <script type=\"text/javascript\" src=\"https://gist.github.com/CamDavidsonPilon/9a987a5f65f612035554/raw/d43d263491078f8fce4a3ff2381fe81c2625e4a7/d3bandits.js\"></script>\n",  | 
 | 835 | +        "\n",  | 
 | 836 | +        "     \n",  | 
 | 837 | +        "     \n",  | 
 | 838 | +        "  </div>\n",  | 
 | 839 | +        "\n",  | 
 | 840 | +        "\n"  | 
 | 841 | +       ],  | 
 | 842 | +       "output_type": "pyout",  | 
 | 843 | +       "prompt_number": 14,  | 
 | 844 | +       "text": [  | 
 | 845 | +        "<IPython.core.display.HTML at 0x56aa208>"  | 
 | 846 | +       ]  | 
 | 847 | +      }  | 
 | 848 | +     ],  | 
 | 849 | +     "prompt_number": 14  | 
 | 850 | +    },  | 
717 | 851 |     {  | 
718 | 852 |      "cell_type": "markdown",  | 
719 | 853 |      "metadata": {},  | 
 | 
0 commit comments