From b33f38dfcfc31d595e7bc4250f490d7224b4a42f Mon Sep 17 00:00:00 2001 From: Maurits Diephuis Date: Mon, 13 Jan 2014 22:26:50 +0100 Subject: [PATCH 1/2] fixed two minor grammar errors and a python typo --- Chapter4_TheGreatestTheoremNeverTold/LawOfLargeNumbers.ipynb | 2 +- Chapter5_LossFunctions/LossFunctions.ipynb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Chapter4_TheGreatestTheoremNeverTold/LawOfLargeNumbers.ipynb b/Chapter4_TheGreatestTheoremNeverTold/LawOfLargeNumbers.ipynb index 570e3256..fde29712 100644 --- a/Chapter4_TheGreatestTheoremNeverTold/LawOfLargeNumbers.ipynb +++ b/Chapter4_TheGreatestTheoremNeverTold/LawOfLargeNumbers.ipynb @@ -489,7 +489,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "One way to determine a prior on the upvote ratio is that look at the historical distribution of upvote ratios. This can be accomplished by scraping Reddit's comments and determining a distribution. There are a few problems with this technique though:\n", + "One way to determine a prior on the upvote ratio is to look at the historical distribution of upvote ratios. This can be accomplished by scraping Reddit's comments and determining a distribution. There are a few problems with this technique though:\n", "\n", "1. Skewed data: The vast majority of comments have very few votes, hence there will be many comments with ratios near the extremes (see the \"triangular plot\" in the above Kaggle dataset), effectively skewing our distribution to the extremes. One could try to only use comments with votes greater than some threshold. Again, problems are encountered. There is a tradeoff between number of comments available to use and a higher threshold with associated ratio precision. \n", "2. Biased data: Reddit is composed of different subpages, called subreddits. Two examples are *r/aww*, which posts pics of cute animals, and *r/politics*. It is very likely that the user behaviour towards comments of these two subreddits are very different: visitors are likely friend and affectionate in the former, and would therefore upvote comments more, compared to the latter, where comments are likely to be controversial and disagreed upon. Therefore not all comments are the same. \n", diff --git a/Chapter5_LossFunctions/LossFunctions.ipynb b/Chapter5_LossFunctions/LossFunctions.ipynb index b5601465..c4e4ee38 100644 --- a/Chapter5_LossFunctions/LossFunctions.ipynb +++ b/Chapter5_LossFunctions/LossFunctions.ipynb @@ -119,7 +119,7 @@ "\n", "Notice that measuring your loss via an *expected value* uses more information from the distribution than the MAP estimate which, if you recall, will only find the maximum value of the distribution and ignore the shape of the distribution. Ignoring information can over-expose yourself to tail risks, like the unlikely hurricane, and leaves your estimate ignorant of how ignorant you really are about the parameter.\n", "\n", - "Similarly, compare this with frequentist methods, that traditionally only aim to minimize the error, and not considering the *loss associated with the result of that error*. Compound this with the fact that frequentist methods are almost guaranteed to never be absolutely accurate. Bayesian point estimates fix this by planning ahead: your estimate is going to be wrong, you might as well err on the right side of wrong." + "Similarly, compare this with frequentist methods, that traditionally only aim to minimize the error, and do not consider the *loss associated with the result of that error*. Compound this with the fact that frequentist methods are almost guaranteed to never be absolutely accurate. Bayesian point estimates fix this by planning ahead: your estimate is going to be wrong, you might as well err on the right side of wrong." ] }, { @@ -583,7 +583,7 @@ "def stock_loss( true_return, yhat, alpha = 100. ):\n", " if true_return*yhat < 0:\n", " #opposite signs, not good\n", - " return alpha*yhat**2 - sign( true_return )*yhat \\\n", + " return alpha*yhat**2 - np.sign( true_return )*yhat \\\n", " + abs( true_return ) \n", " else:\n", " return abs( true_return - yhat )\n", From 8e4a64cfe80ac9fcc852c9c3b9d0f36f48afe5b1 Mon Sep 17 00:00:00 2001 From: Maurits Diephuis Date: Mon, 13 Jan 2014 22:40:33 +0100 Subject: [PATCH 2/2] Added two missing words --- Chapter4_TheGreatestTheoremNeverTold/LawOfLargeNumbers.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter4_TheGreatestTheoremNeverTold/LawOfLargeNumbers.ipynb b/Chapter4_TheGreatestTheoremNeverTold/LawOfLargeNumbers.ipynb index fde29712..350472cb 100644 --- a/Chapter4_TheGreatestTheoremNeverTold/LawOfLargeNumbers.ipynb +++ b/Chapter4_TheGreatestTheoremNeverTold/LawOfLargeNumbers.ipynb @@ -674,7 +674,7 @@ "\n", "### Sorting!\n", "\n", - "We have been ignoring the goal of this exercise: how do we sort the comments from *best to worst*? Of course, we cannot sort distributions, we must sort scalar numbers. There are many ways to distill a distribution down to a scalar: expressing the distribution through its expected value, or mean, is one way. Choosing the mean bad choice though. This is because the mean does not take into account the uncertainty of distributions.\n", + "We have been ignoring the goal of this exercise: how do we sort the comments from *best to worst*? Of course, we cannot sort distributions, we must sort scalar numbers. There are many ways to distill a distribution down to a scalar: expressing the distribution through its expected value, or mean, is one way. Choosing the mean is a bad choice though. This is because the mean does not take into account the uncertainty of distributions.\n", "\n", "I suggest using the *95% least plausible value*, defined as the value such that there is only a 5% chance the true parameter is lower (think of the lower bound on the 95% credible region). Below are the posterior distributions with the 95% least-plausible value plotted:" ]