Skip to content

Commit 3393808

Browse files
committed
Improve plotting syntax and remove re-specification of seed
1 parent fb3184b commit 3393808

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

source/inference.md

+12-18
Original file line numberDiff line numberDiff line change
@@ -791,21 +791,18 @@ large enough sample.
791791
792792
# plot sample distributions for n = 10, 20, 50, 100, 200 and population distribution
793793
sample_distribution_dict = {}
794-
np.random.seed(12)
795794
for sample_n in [10, 20, 50, 100, 200]:
796795
sample = airbnb.sample(sample_n)
797796
sample_distribution_dict[f"sample_distribution_{sample_n}"] = (
798-
alt.Chart(sample, title=f"n = {sample_n}")
799-
.mark_bar()
800-
.encode(
797+
alt.Chart(sample, title=f"n = {sample_n}").mark_bar().encode(
801798
x=alt.X(
802799
"price",
803800
bin=alt.Bin(extent=[0, 600], step=20),
804801
title="Price per night (Canadian dollars)",
805802
),
806803
y=alt.Y("count()", title="Count"),
807804
)
808-
).properties(width=350, height=150)
805+
).properties(height=150)
809806
# add title and standardize the x axis ticks for population histogram
810807
population_distribution.title = "Population distribution"
811808
population_distribution.encoding["x"]["bin"] = alt.Bin(extent=[0, 600], step=20)
@@ -986,19 +983,16 @@ Let's take a look at histograms of the first six replicates of our bootstrap sam
986983
:tags: []
987984
988985
six_bootstrap_samples = boot20000.query("replicate < 6")
989-
990-
(
991-
alt.Chart(six_bootstrap_samples)
992-
.mark_bar()
993-
.encode(
994-
x=alt.X(
995-
"price",
996-
bin=alt.Bin(maxbins=20),
997-
title="Price per night (Canadian dollars)",
998-
),
999-
y=alt.Y("count()", title="Count"),
1000-
).properties(width=250, height=200)
1001-
.facet("replicate", columns=3)
986+
alt.Chart(six_bootstrap_samples, height=150).mark_bar().encode(
987+
x=alt.X(
988+
"price",
989+
bin=alt.Bin(maxbins=20),
990+
title="Price per night (Canadian dollars)",
991+
),
992+
y=alt.Y("count()", title="Count")
993+
).facet(
994+
"replicate",
995+
columns=2
1002996
)
1003997
```
1004998

0 commit comments

Comments
 (0)