Skip to content

Commit

Permalink
Rearrange and clarify
Browse files Browse the repository at this point in the history
  • Loading branch information
jswelling committed Feb 1, 2024
1 parent cc48bd8 commit 9307900
Showing 1 changed file with 51 additions and 21 deletions.
72 changes: 51 additions & 21 deletions notebooks/seaborn_workbook_3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c30ec428",
"id": "0695faeb",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -428,7 +428,7 @@
},
{
"cell_type": "markdown",
"id": "760523e6",
"id": "a2dbd581",
"metadata": {},
"source": [
"## Bootstrapped Confidence Intervals vs. Standard Deviation\n",
Expand All @@ -439,7 +439,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f55a8865",
"id": "4ec45b94",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -448,7 +448,7 @@
},
{
"cell_type": "markdown",
"id": "ccf01e46",
"id": "c0adf436",
"metadata": {},
"source": [
"### Turn off the error bars entirely"
Expand All @@ -457,7 +457,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "66f7afeb",
"id": "88e19a82",
"metadata": {
"scrolled": false
},
Expand All @@ -468,82 +468,112 @@
},
{
"cell_type": "markdown",
"id": "0676df46",
"id": "4e068013",
"metadata": {},
"source": [
"### *percentile interval* (non-parametric)"
"### *standard deviation* (parametric)\n",
"1 standard deviation on each side of the mean by default, so for normal data 68% will fall within the range."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d53750a7",
"id": "3180b969",
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"sns.relplot(x=\"timepoint\", y=\"signal\", kind=\"line\", data=fmri_df, col=\"region\", hue=\"event\", errorbar=\"pi\");"
"sns.relplot(x=\"timepoint\", y=\"signal\", kind=\"line\", data=fmri_df, col=\"region\", hue=\"event\", errorbar=\"sd\");"
]
},
{
"cell_type": "markdown",
"id": "6d81bce6",
"id": "c0944dae",
"metadata": {},
"source": [
"### *confidence interval* (non-parametric)"
"### *standard error* (parametric)\n",
"How far is the estimated mean likely to be from the real mean?\n",
"* This one is just standard deviation over sqrt(number of samples)\n",
"* Thus, more samples makes the standard error smaller"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fc19f6de",
"id": "cd89f0fc",
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"sns.relplot(x=\"timepoint\", y=\"signal\", kind=\"line\", data=fmri_df, col=\"region\", hue=\"event\", errorbar=\"ci\");"
"sns.relplot(x=\"timepoint\", y=\"signal\", kind=\"line\", data=fmri_df, col=\"region\", hue=\"event\", errorbar=\"se\");"
]
},
{
"cell_type": "markdown",
"id": "dac75ce9",
"id": "f7ed22f7",
"metadata": {},
"source": [
"### *standard deviation* (parametric)"
"### *percentile interval* (non-parametric)\n",
"How confident are we that a given sample will fall in the range?\n",
"* 95% confidence by default - note that it is wider than the 'standard deviation' bars\n",
"* Note also that it can be assymmetric, unlike the parametric statistics."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "35d7435d",
"id": "694e6a7b",
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"sns.relplot(x=\"timepoint\", y=\"signal\", kind=\"line\", data=fmri_df, col=\"region\", hue=\"event\", errorbar=\"sd\");"
"sns.relplot(x=\"timepoint\", y=\"signal\", kind=\"line\", data=fmri_df, col=\"region\", hue=\"event\", errorbar=\"pi\");"
]
},
{
"cell_type": "markdown",
"id": "fbd9737b",
"id": "3ed82706",
"metadata": {},
"source": [
"### *standard error* (parametric)"
"### Repeat that with a 50% confidence interval.\n",
"This is equivalent to the Q1/median/Q3 graphs we were drawing earlier."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "be4c2ea9",
"id": "59acff5d",
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"sns.relplot(x=\"timepoint\", y=\"signal\", kind=\"line\", data=fmri_df, col=\"region\", hue=\"event\", errorbar=\"se\");"
"sns.relplot(x=\"timepoint\", y=\"signal\", kind=\"line\", data=fmri_df, col=\"region\", hue=\"event\", errorbar=(\"pi\",50));"
]
},
{
"cell_type": "markdown",
"id": "8fc54cb8",
"metadata": {},
"source": [
"### *confidence interval* (non-parametric)\n",
"These are computed by bootstrapping, which takes a bit of time.\n",
"What we see is the percentile interval of the bootstrap distribution."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "61789053",
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"sns.relplot(x=\"timepoint\", y=\"signal\", kind=\"line\", data=fmri_df, col=\"region\", hue=\"event\", errorbar=\"ci\");"
]
},
{
Expand Down

0 comments on commit 9307900

Please sign in to comment.