|
20 | 20 | "cell_type": "markdown", |
21 | 21 | "metadata": {}, |
22 | 22 | "source": [ |
23 | | - "Statisticians can be a sour bunch. Instead of considering their winnings, they only measure how much they have lost. In fact, they consider their wins as *negative loses*. But what's interesting is *how they measure their losses.*\n", |
| 23 | + "Statisticians can be a sour bunch. Instead of considering their winnings, they only measure how much they have lost. In fact, they consider their wins as *negative losses*. But what's interesting is *how they measure their losses.*\n", |
24 | 24 | "\n", |
25 | 25 | "For example, consider the following example:\n", |
26 | 26 | "\n", |
|
173 | 173 | "& \\text{Toronto} \\sim \\text{Normal}(12 000, 3000 )\\\\\\\\\n", |
174 | 174 | "\\end{align}\n", |
175 | 175 | "\n", |
176 | | - "For example, I believe that the true price of the trip to Toronto is 12 000 dollars, and that there is a 68.2% chance the price falls 1 standard deviation away from this, i.e. my confidence is that there is a 68.2% chance the snowblower is in [9 000, 15 000].\n", |
| 176 | + "For example, I believe that the true price of the trip to Toronto is 12 000 dollars, and that there is a 68.2% chance the price falls 1 standard deviation away from this, i.e. my confidence is that there is a 68.2% chance the trip is in [9 000, 15 000].\n", |
177 | 177 | "\n", |
178 | 178 | "We can create some PyMC code to perform inference on the true price of the suite." |
179 | 179 | ] |
|
518 | 518 | "\n", |
519 | 519 | "For some loss functions, the Bayes action is known in closed form. We list some of them below:\n", |
520 | 520 | "\n", |
521 | | - "- If using the mean-squared loss, the Bayes action is the mean the posterior distribution, i.e. the value \n", |
| 521 | + "- If using the mean-squared loss, the Bayes action is the mean of the posterior distribution, i.e. the value \n", |
522 | 522 | "$$ E_{\\theta}\\left[ \\theta \\right] $$\n", |
523 | 523 | "\n", |
524 | | - "> minimizes $E_{\\theta}\\left[ \\; (\\theta - \\hat{\\theta})^2 \\; \\right]$. Computationally this requires us the calculate the average of the posterior samples [See chapter 4 on The Law of Large Numbers]\n", |
| 524 | + "> minimizes $E_{\\theta}\\left[ \\; (\\theta - \\hat{\\theta})^2 \\; \\right]$. Computationally this requires us to calculate the average of the posterior samples [See chapter 4 on The Law of Large Numbers]\n", |
525 | 525 | "\n", |
526 | 526 | "- Whereas the *median* of the posterior distribution minimizes the expected absolute-loss. The sample median of the posterior samples is an appropriate and very accurate approximation to the true median.\n", |
527 | 527 | "\n", |
|
552 | 552 | "##### Example: Financial prediction\n", |
553 | 553 | "\n", |
554 | 554 | "\n", |
555 | | - "Suppose the future return of a stock price is very small, say 0.01 (or 1%). We have a model that predicts the stock's future price, and our profit and loss is directly tied to us acting on the prediction. How should be measure the loss associated with the model's predictions, and subsequent future predictions? A squared-error loss is agnostic to the signage and would penalize a prediction of -0.01 equally as bad a prediction of 0.03:\n", |
| 555 | + "Suppose the future return of a stock price is very small, say 0.01 (or 1%). We have a model that predicts the stock's future price, and our profit and loss is directly tied to us acting on the prediction. How should we measure the loss associated with the model's predictions, and subsequent future predictions? A squared-error loss is agnostic to the signage and would penalize a prediction of -0.01 equally as bad a prediction of 0.03:\n", |
556 | 556 | "\n", |
557 | 557 | "$$ \\(0.01 - (-0.01) \\)^2 = (0.01 - 0.03)^2 = 0.004$$\n", |
558 | 558 | "\n", |
|
868 | 868 | "cell_type": "markdown", |
869 | 869 | "metadata": {}, |
870 | 870 | "source": [ |
871 | | - "The loss function in this problem is very complicated. For the very determined, the loss function is contained in the file DarkWorldsMetric.py in parent folder. Though I suggest not reading it all, suffice to say the loss function is about 160 lines of code — not something that can be written down in a single mathematical line. The loss function attempts to measure the accuracy of prediction, in a Euclidean distance sense, and that no shift-bias is present. More details can be found on the metric's [main page](http://www.kaggle.com/c/DarkWorlds/details/evaluation). \n", |
| 871 | + "The loss function in this problem is very complicated. For the very determined, the loss function is contained in the file DarkWorldsMetric.py in the parent folder. Though I suggest not reading it all, suffice to say the loss function is about 160 lines of code — not something that can be written down in a single mathematical line. The loss function attempts to measure the accuracy of prediction, in a Euclidean distance sense, and that no shift-bias is present. More details can be found on the metric's [main page](http://www.kaggle.com/c/DarkWorlds/details/evaluation). \n", |
872 | 872 | "\n", |
873 | 873 | "We will attempt to implement Tim's winning solution using PyMC and our knowledge of loss functions." |
874 | 874 | ] |
|
947 | 947 | "\n", |
948 | 948 | "Each sky has one, two or three dark matter halos in it. Tim's solution details that his prior distribution of halo positions was uniform, i.e.\n", |
949 | 949 | "\n", |
950 | | - "\\begin{align*}\n", |
| 950 | + "\\begin{align}\n", |
951 | 951 | "& x_i \\sim \\text{Uniform}( 0, 4200)\\\\\\\\\n", |
952 | 952 | "& y_i \\sim \\text{Uniform}( 0, 4200), \\;\\; i=1,2,3\\\\\\\\\n", |
953 | | - "\\end{align*}\n", |
| 953 | + "\\end{align}\n", |
954 | 954 | "\n", |
955 | 955 | "Tim and other competitors noted that most skies had one large halo and other halos, if present, were much smaller. Larger halos, having more mass, will influence the surrounding galaxies more. He decided that the large halos would have a mass distributed as a *log*-uniform random variable between 40 and 180 i.e.\n", |
956 | 956 | "\n", |
|
0 commit comments