{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"hconcat": [
{
"data": {
"sequence": {
"start": 1,
"stop": 1001,
"step": 1,
"as": "index"
}
},
"transform": [
{
"calculate": "clamp(620 + 50 * sampleNormal(0, 1), 200, 900)",
"as": "credit_score"
}
],
"layer": [
{
"mark": "point",
"encoding": {
"x": {
"field": "index",
"type": "quantitative",
"title": "Index"
},
"y": {
"field": "credit_score",
"type": "quantitative",
"title": "Credit Score",
"scale": {
"domain": [
400,
900
]
}
},
"color": {
"value": "grey"
},
"size": {
"value": 10
}
}
},
{
"transform": [
{
"aggregate": [
{
"op": "mean",
"field": "credit_score",
"as": "mean_credit_score"
},
{
"op": "stdev",
"field": "credit_score",
"as": "stdev_credit_score"
}
]
},
{
"calculate": "datum.mean_credit_score + datum.stdev_credit_score",
"as": "mean_plus_stdev"
},
{
"calculate": "datum.mean_credit_score - datum.stdev_credit_score",
"as": "mean_minus_stdev"
}
],
"layer": [
{
"mark": {
"type": "rule",
"color": "blue"
},
"encoding": {
"y": {
"field": "mean_credit_score",
"type": "quantitative"
}
}
},
{
"mark": {
"type": "rule",
"color": "green",
"strokeDash": [
4,
2
]
},
"encoding": {
"y": {
"field": "mean_plus_stdev",
"type": "quantitative"
}
}
},
{
"mark": {
"type": "rule",
"color": "green",
"strokeDash": [
4,
2
]
},
"encoding": {
"y": {
"field": "mean_minus_stdev",
"type": "quantitative"
}
}
}
]
}
],
"title": "Population Data"
},
{
"data": {
"sequence": {
"start": 1,
"stop": 1001,
"step": 1,
"as": "index"
}
},
"transform": [
{
"calculate": "clamp(620 + 50 * sampleNormal(0, 1), 200, 900)",
"as": "credit_score"
},
{
"window": [
{
"op": "rank",
"as": "rank"
}
]
},
{
"filter": "datum.rank <= 100"
}
],
"layer": [
{
"mark": "point",
"encoding": {
"x": {
"field": "index",
"type": "quantitative",
"title": "Index"
},
"y": {
"field": "credit_score",
"type": "quantitative",
"title": "Credit Score",
"scale": {
"domain": [
400,
900
]
}
},
"color": {
"value": "blue"
},
"size": {
"value": 10
}
}
},
{
"transform": [
{
"aggregate": [
{
"op": "mean",
"field": "credit_score",
"as": "mean_credit_score"
},
{
"op": "stdev",
"field": "credit_score",
"as": "stdev_credit_score"
}
]
},
{
"calculate": "datum.mean_credit_score + datum.stdev_credit_score",
"as": "mean_plus_stdev"
},
{
"calculate": "datum.mean_credit_score - datum.stdev_credit_score",
"as": "mean_minus_stdev"
}
],
"layer": [
{
"mark": {
"type": "rule",
"color": "blue"
},
"encoding": {
"y": {
"field": "mean_credit_score",
"type": "quantitative"
}
}
},
{
"mark": {
"type": "rule",
"color": "green",
"strokeDash": [
4,
2
]
},
"encoding": {
"y": {
"field": "mean_plus_stdev",
"type": "quantitative"
}
}
},
{
"mark": {
"type": "rule",
"color": "green",
"strokeDash": [
4,
2
]
},
"encoding": {
"y": {
"field": "mean_minus_stdev",
"type": "quantitative"
}
}
}
]
}
],
"title": "Simple Random Sampling"
},
{
"data": {
"sequence": {
"start": 1,
"stop": 1001,
"step": 1,
"as": "index"
}
},
"transform": [
{
"calculate": "clamp(620 + 50 * sampleNormal(0, 1), 200, 900)",
"as": "credit_score"
},
{
"filter": "(datum.index - 1) % 10 == 0"
}
],
"layer": [
{
"mark": "point",
"encoding": {
"x": {
"field": "index",
"type": "quantitative",
"title": "Index"
},
"y": {
"field": "credit_score",
"type": "quantitative",
"title": "Credit Score",
"scale": {
"domain": [
400,
900
]
}
},
"color": {
"value": "green"
},
"size": {
"value": 10
}
}
},
{
"transform": [
{
"aggregate": [
{
"op": "mean",
"field": "credit_score",
"as": "mean_credit_score"
},
{
"op": "stdev",
"field": "credit_score",
"as": "stdev_credit_score"
}
]
},
{
"calculate": "datum.mean_credit_score + datum.stdev_credit_score",
"as": "mean_plus_stdev"
},
{
"calculate": "datum.mean_credit_score - datum.stdev_credit_score",
"as": "mean_minus_stdev"
}
],
"layer": [
{
"mark": {
"type": "rule",
"color": "blue"
},
"encoding": {
"y": {
"field": "mean_credit_score",
"type": "quantitative"
}
}
},
{
"mark": {
"type": "rule",
"color": "green",
"strokeDash": [
4,
2
]
},
"encoding": {
"y": {
"field": "mean_plus_stdev",
"type": "quantitative"
}
}
},
{
"mark": {
"type": "rule",
"color": "green",
"strokeDash": [
4,
2
]
},
"encoding": {
"y": {
"field": "mean_minus_stdev",
"type": "quantitative"
}
}
}
]
}
],
"title": "Systematic Sampling"
}
]
}