{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "Binomial Distribution PMF for different parameters",
"data": {
"sequence": {
"start": 0,
"stop": 20,
"step": 1,
"as": "k"
}
},
"transform": [
{
"calculate": "pow(0.3, datum.k) * pow(0.7, 10-datum.k) * (factorial(10) / (factorial(datum.k) * factorial(10-datum.k)))",
"as": "y1"
},
{
"calculate": "pow(0.5, datum.k) * pow(0.5, 20-datum.k) * (factorial(20) / (factorial(datum.k) * factorial(20-datum.k)))",
"as": "y2"
},
{
"calculate": "pow(0.7, datum.k) * pow(0.3, 15-datum.k) * (factorial(15) / (factorial(datum.k) * factorial(15-datum.k)))",
"as": "y3"
}
],
"hconcat": [
{
"width": 250,
"height": 200,
"title": "n=10, p=0.3",
"mark": "bar",
"encoding": {
"x": {
"field": "k",
"type": "ordinal",
"title": "Number of Successes"
},
"y": {
"field": "y1",
"type": "quantitative",
"title": "Probability",
"scale": {
"domain": [
0,
0.3
]
}
},
"color": {
"value": "#004976"
}
}
},
{
"width": 250,
"height": 200,
"title": "n=20, p=0.5",
"mark": "bar",
"encoding": {
"x": {
"field": "k",
"type": "ordinal",
"title": "Number of Successes"
},
"y": {
"field": "y2",
"type": "quantitative",
"title": "Probability",
"scale": {
"domain": [
0,
0.2
]
}
},
"color": {
"value": "#7A0045"
}
}
},
{
"width": 250,
"height": 200,
"title": "n=15, p=0.7",
"mark": "bar",
"encoding": {
"x": {
"field": "k",
"type": "ordinal",
"title": "Number of Successes"
},
"y": {
"field": "y3",
"type": "quantitative",
"title": "Probability",
"scale": {
"domain": [
0,
0.25
]
}
},
"color": {
"value": "#486300"
}
}
}
]
}