{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "Comparison of Normal, Binomial, and Poisson Distributions",
"hconcat": [
{
"width": 250,
"height": 250,
"title": "Normal Distribution",
"data": {
"sequence": {
"start": -4,
"stop": 4,
"step": 0.1,
"as": "x"
}
},
"transform": [
{
"calculate": "1 / (sqrt(2 * PI)) * exp(-0.5 * pow(datum.x, 2))",
"as": "y"
}
],
"layer": [
{
"mark": {
"type": "line",
"color": "blue"
},
"encoding": {
"x": {
"field": "x",
"type": "quantitative",
"title": "Value"
},
"y": {
"field": "y",
"type": "quantitative",
"title": "Probability Density"
}
}
},
{
"mark": {
"type": "rule",
"color": "red",
"strokeDash": [
4,
4
]
},
"encoding": {
"x": {
"datum": 0
}
}
},
{
"mark": {
"type": "text",
"align": "left",
"dx": 5
},
"encoding": {
"x": {
"datum": 0
},
"y": {
"datum": 0.4
},
"text": {
"value": "Mean, Median, Mode"
}
}
}
]
},
{
"width": 250,
"height": 250,
"title": "Binomial Distribution (n=10, p=0.5)",
"data": {
"sequence": {
"start": 0,
"stop": 10,
"step": 1,
"as": "k"
}
},
"transform": [
{
"calculate": "pow(0.5, datum.k) * pow(0.5, 10-datum.k) * (factorial(10) / (factorial(datum.k) * factorial(10-datum.k)))",
"as": "y"
}
],
"mark": "bar",
"encoding": {
"x": {
"field": "k",
"type": "ordinal",
"title": "Number of Successes"
},
"y": {
"field": "y",
"type": "quantitative",
"title": "Probability"
}
}
},
{
"width": 250,
"height": 250,
"title": "Poisson Distribution (λ=5)",
"data": {
"sequence": {
"start": 0,
"stop": 15,
"step": 1,
"as": "k"
}
},
"transform": [
{
"calculate": "exp(-5) * pow(5, datum.k) / factorial(datum.k)",
"as": "y"
}
],
"mark": "bar",
"encoding": {
"x": {
"field": "k",
"type": "ordinal",
"title": "Number of Events"
},
"y": {
"field": "y",
"type": "quantitative",
"title": "Probability"
}
}
}
],
"config": {
"view": {
"stroke": null
},
"axis": {
"labelFontSize": 12,
"titleFontSize": 14
},
"title": {
"fontSize": 16
}
}
}