Skip to content

Commit

Permalink
brush up changes to visualization_2
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoruiyliu committed Sep 20, 2024
1 parent 7839d3f commit 0ff158a
Show file tree
Hide file tree
Showing 57 changed files with 112 additions and 116 deletions.
2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

200 changes: 99 additions & 101 deletions docs/visualization_2/visualization_2.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
26 changes: 12 additions & 14 deletions visualization_2/visualization_2.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ plt.xlim(-3, 10)
plt.ylim(0, 0.5);
```

Alternatively, we can use `sns.histplot`. This plot also visualizes the underlying bins as a histogram.

```{python}
#| code-fold: true
sns.histplot(data, bins=2, kde=True, stat="density", kde_kws=dict(cut=3, bw_method=0.65))
plt.xlabel("Data")
plt.xlim(-3, 10)
plt.ylim(0, 0.5);
```

#### Step 1: Place a Kernel at Each Data Point

To begin generating a density curve, we need to choose a **kernel** and **bandwidth value ($\alpha$)**. What are these exactly?
Expand Down Expand Up @@ -207,20 +218,7 @@ plt.ylim(0, 0.5)
plt.xlabel("Data")
plt.ylabel("Density")
sns.kdeplot(data, bw_method=0.65)
sns.histplot(data, stat="density", bins=2);
```

An alternative method to generate the above KDE is shown below, this time using `sns.histplot`'s arguments.

```{python}
#| code-fold: true
plt.xlim(-3, 10)
plt.ylim(0, 0.5)
plt.xlabel("Data")
plt.ylabel("Density")
sns.histplot(data, bins=2, kde=True, stat="density", kde_kws=dict(cut=3, bw_method=0.65))
plot_kde(gaussian_kernel, data, a=1)
```

### Kernel Functions and Bandwidths
Expand Down

0 comments on commit 0ff158a

Please sign in to comment.