{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "Uniform Distribution PDF and CDF",
"data": {
"sequence": {
"start": 0,
"stop": 10,
"step": 0.1,
"as": "x"
}
},
"transform": [
{
"calculate": "datum.x >= 2 && datum.x <= 8 ? 1/6 : 0",
"as": "pdf"
},
{
"calculate": "datum.x < 2 ? 0 : datum.x > 8 ? 1 : (datum.x - 2) / 6",
"as": "cdf"
}
],
"hconcat": [
{
"width": 300,
"height": 200,
"title": "PDF (a=2, b=8)",
"mark": "line",
"encoding": {
"x": {
"field": "x",
"type": "quantitative",
"title": "x"
},
"y": {
"field": "pdf",
"type": "quantitative",
"title": "Density"
},
"color": {
"value": "#004976"
}
}
},
{
"width": 300,
"height": 200,
"title": "CDF (a=2, b=8)",
"mark": "line",
"encoding": {
"x": {
"field": "x",
"type": "quantitative",
"title": "x"
},
"y": {
"field": "cdf",
"type": "quantitative",
"title": "Cumulative Probability"
},
"color": {
"value": "#7A0045"
}
}
}
]
}