{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "Statistical Analysis of Simulation Results",
"data": {
"sequence": {
"start": 0,
"stop": 10000,
"step": 1,
"as": "index"
}
},
"transform": [
{
"calculate": "50 * exp((0.03 - 0.05 * 0.05 / 2) * 1 + 0.05 * sqrt(1) * sampleNormal(0, 1))",
"as": "final_price"
}
],
"width": 500,
"height": 300,
"layer": [
{
"mark": {
"type": "bar",
"tooltip": true
},
"encoding": {
"x": {
"field": "final_price",
"type": "quantitative",
"bin": {
"maxbins": 50
},
"title": "Final Stock Price"
},
"y": {
"aggregate": "count",
"type": "quantitative",
"title": "Frequency"
}
}
},
{
"mark": {
"type": "rule",
"color": "red"
},
"encoding": {
"x": {
"aggregate": "mean",
"field": "final_price",
"type": "quantitative"
}
}
},
{
"mark": {
"type": "rule",
"color": "green"
},
"transform": [
{
"quantile": "final_price",
"probs": [
0.05
],
"as": [
"prob",
"value"
]
}
],
"encoding": {
"x": {
"field": "value",
"type": "quantitative"
}
}
},
{
"mark": {
"type": "text",
"align": "left",
"dx": 5,
"dy": -5
},
"encoding": {
"x": {
"aggregate": "mean",
"field": "final_price",
"type": "quantitative"
},
"text": {
"value": "Mean"
}
}
},
{
"mark": {
"type": "text",
"align": "left",
"dx": 5,
"dy": -5
},
"transform": [
{
"quantile": "final_price",
"probs": [
0.05
],
"as": [
"prob",
"value"
]
}
],
"encoding": {
"x": {
"field": "value",
"type": "quantitative"
},
"text": {
"value": "5% VaR"
}
}
}
]
}