Skip to content

Commit 05d725d

Browse files
loss functions
1 parent 335cddf commit 05d725d

File tree

6 files changed

+499
-86
lines changed

6 files changed

+499
-86
lines changed

Chapter1_Introduction/Chapter1_Introduction.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -784,12 +784,12 @@
784784
"cell_type": "code",
785785
"collapsed": false,
786786
"input": [
787-
"#type you code here."
787+
"#type your code here."
788788
],
789789
"language": "python",
790790
"metadata": {},
791791
"outputs": [],
792-
"prompt_number": 15
792+
"prompt_number": 17
793793
},
794794
{
795795
"cell_type": "markdown",
@@ -802,7 +802,7 @@
802802
"cell_type": "code",
803803
"collapsed": false,
804804
"input": [
805-
"#type you code here."
805+
"#type your code here."
806806
],
807807
"language": "python",
808808
"metadata": {},
@@ -820,7 +820,7 @@
820820
"cell_type": "markdown",
821821
"metadata": {},
822822
"source": [
823-
"4.\\ What is the mean of $\\lambda_1$ **given** $\\tau$ is less than 45. "
823+
"4\\. What is the mean of $\\lambda_1$ **given** $\\tau$ is less than 45. "
824824
]
825825
},
826826
{

Chapter2_/Chapter2_.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,22 +279,22 @@
279279
"Our dataset contains 36 cohorts, each cohort has variable:\n",
280280
"\n",
281281
"- age: in five-year age groups coded 1 to 9 for 40-44, 45-49, 50-54, 55-59, 60-64, 65-69, 70-74, 75-79, 80+.\n",
282-
"- cigar/pipe smoking status: 0 if do not smoke cigars/pipe, 1 if they do.\n",
283-
"- cigarette smoking status: 0 if do not smoke cigarette, 1 if they do.\n",
282+
"- cigar/pipe smoking status: 1 if the only smoke cigars/pipes, 0 else.\n",
283+
"- cigar & cigarette smoking status: 1 if the smoke *both* cigars/pipes and cigarettes, 0 else.\n",
284+
"- cigarette smoking status: 1 if the only smoke cigarettes, 0 else.\n",
284285
"- population: the population, in hundreds of thousands, of the age group *and* smoking status cohort.\n",
285286
"- deaths: number of lung cancer deaths in a year.\n",
286287
"\n",
287288
"We will try to fit the number of deaths of lung cancer to age, smoking status and population. Standard linear regression won't work as we are trying to predict integer count data, and linear regression cannot garuntee this. Again, a Poisson random variable is appropriate. As a Poisson variable is fully defined by its parameter $\\lambda$, we only need to model this.\n",
288289
"\n",
289-
"This example is quite different from our last example on text-messaging rates, though the two look similar. We are not trying to estimate a *global* $\\lambda$, that is single parameter $\\lambda$ that determines the all the observations, but are actual trying to model a unique $\\lambda$ for each data point using the observed variables, i.e. $\\lambda_i = f( \\text{age}_i, \\text{cigar or pipe smoking status}_i, \\text{cigarette smoking status}_i \\text{population}_i )$. \n",
290+
"This example is quite different from our last example on text-messaging rates, though the two look similar. We are not trying to estimate a *global* $\\lambda$, that is single parameter $\\lambda$ that determines the all the observations, but are actual trying to model a unique $\\lambda$ for each data point using the observed variables, i.e. $\\lambda_i = f( \\mathbf{x}_i )$. \n",
290291
"\n",
291292
"The simplest function to connect the variables to $\\lambda$ is to use a *link function* and a linear combination of the variables. \n",
292293
"\n",
293294
"\n",
294295
"\\begin{align}\n",
295296
"& D_i \\sim \\text{Poi}(\\lambda_i) \\\\\\\\\n",
296-
"& \\lambda_i = \\exp \\left( \\beta_0 \\text{Age}_i + \\beta_1\\text{cigar or pipe smoking status}_i \\\\\\\\ + \\beta_2\\text{cigarette smoking status}_i + \\beta_3 \\text{population}_i + \\beta_4 \\right)\n",
297-
"\\end{align}\n",
297+
"& \\lambda_i = \\exp \\left( \\beta^T \\mathbf{x}_i \\right)\n",
298298
"\n",
299299
"We require the $\\exp$ *link function* because the linear combination of variables may be negative but the parameter $\\lambda_i$ must always be positive, hence exponentiating fixes this. The model above connects the variables and the *expected* number of deaths per cohort (recall the mean of a Poisson random variable is equal to its parameter $\\lambda$).\n",
300300
"\n",

Chapter4_/LossFunctions.ipynb

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)