{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "Horizontal layout of histogram, line chart, and product chart with centered plus and equal signs.",
"data": {
"sequence": {
"start": 1,
"stop": 1000,
"step": 1,
"as": "EventCount"
}
},
"transform": [
{
"calculate": "samplePoisson(50)",
"as": "NumberOfEvents"
},
{
"calculate": "sampleLogNormal(10, 1)",
"as": "AvgSeverity"
},
{
"calculate": "datum.NumberOfEvents * datum.AvgSeverity",
"as": "Product"
}
],
"hconcat": [
{
"title": [
"Frequency Histogram",
"Poisson Distribution (λ=50)"
],
"width": 250,
"height": 250,
"mark": "bar",
"transform": [
{
"bin": {
"maxbins": 50
},
"field": "NumberOfEvents",
"as": [
"binnedNumberOfEvents",
"binnedNumberOfEventsEnd"
]
},
{
"aggregate": [
{
"op": "count",
"as": "Frequency"
}
],
"groupby": [
"binnedNumberOfEvents",
"binnedNumberOfEventsEnd"
]
},
{
"calculate": "datum.Frequency / 1000 / (datum.binnedNumberOfEventsEnd - datum.binnedNumberOfEvents)",
"as": "Density"
}
],
"encoding": {
"x": {
"field": "binnedNumberOfEvents",
"type": "quantitative",
"axis": {
"title": "Number of Events"
}
},
"y": {
"field": "Density",
"type": "quantitative",
"axis": {
"title": "Density"
}
},
"color": {
"value": "steelblue"
}
}
},
{
"width": 50,
"height": 250,
"mark": {
"type": "text",
"align": "center",
"baseline": "middle",
"fontSize": 30,
"text": "+"
}
},
{
"title": [
"Severity Distribution",
"Lognormal Distribution (μ=2, σ=1)"
],
"width": 250,
"height": 250,
"mark": "line",
"transform": [
{
"density": "AvgSeverity",
"bandwidth": 50000,
"counts": true
}
],
"encoding": {
"x": {
"field": "value",
"type": "quantitative",
"axis": {
"title": "Average Severity"
}
},
"y": {
"field": "density",
"type": "quantitative",
"axis": {
"title": "Density"
}
},
"color": {
"value": "steelblue"
}
}
},
{
"width": 50,
"height": 250,
"mark": {
"type": "text",
"align": "center",
"baseline": "middle",
"fontSize": 30,
"text": "="
}
},
{
"title": [
"Loss Distribution",
"Frequency x Avg Severity"
],
"width": 250,
"height": 250,
"mark": "line",
"transform": [
{
"density": "Product",
"bandwidth": 1000000,
"counts": true
}
],
"encoding": {
"x": {
"field": "value",
"type": "quantitative",
"axis": {
"title": "Loss"
}
},
"y": {
"field": "density",
"type": "quantitative",
"axis": {
"title": "Density"
}
},
"color": {
"value": "steelblue"
}
}
}
]
}