Follow ______ on twitter.

3.1.1 Probability Distributions in Risk Analysis

Code

Vega-Lite Chart

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "config": {
    "view": {
      "continuousWidth": 250,
      "continuousHeight": 250
    }
  },
  "hconcat": [
    {
      "hconcat": [
        {
          "title": [
            "Probability Density Function (PDF) of",
            "Lognormal Distribution (μ=0, σ=0.5)"
          ],
          "data": {
            "sequence": {
              "start": 0,
              "stop": 8,
              "step": 0.1,
              "as": "Value"
            }
          },
          "transform": [
            {
              "calculate": "densityLogNormal(datum.Value, 1, 0.5)",
              "as": "Density"
            }
          ],
          "layer": [
            {
              "mark": {
                "type": "line",
                "color": "green"
              },
              "height": 250,
              "width": 250,
              "encoding": {
                "x": {
                  "field": "Value",
                  "type": "quantitative",
                  "title": "Value"
                },
                "y": {
                  "field": "Density",
                  "type": "quantitative",
                  "title": "Probability"
                }
              }
            }
          ]
        },
        {
          "title": [
            "Cumulative Distribution Function (CDF) of",
            "Lognormal Distribution (μ=0, σ=0.5)"
          ],
          "data": {
            "sequence": {
              "start": 0,
              "stop": 8,
              "step": 0.1,
              "as": "Value"
            }
          },
          "transform": [
            {
              "calculate": "0.5 * (1 + erf((log(datum.Value) - 1) / (0.5 * sqrt(2))))",
              "as": "Cumulative"
            }
          ],
          "layer": [
            {
              "mark": {
                "type": "line",
                "color": "blue"
              },
              "height": 250,
              "width": 250,
              "encoding": {
                "x": {
                  "field": "Value",
                  "type": "quantitative",
                  "title": "Value"
                },
                "y": {
                  "field": "Cumulative",
                  "type": "quantitative",
                  "title": "Cumulative Probability"
                }
              }
            }
          ]
        }
      ]
    },
    {
      "hconcat": [
        {
          "title": [
            "Probability Mass Function (PMF) of",
            "Poisson Distribution (λ = 4)"
          ],
          "data": {
            "sequence": {
              "start": 0,
              "stop": 15,
              "step": 1,
              "as": "Value"
            }
          },
          "transform": [
            {
              "calculate": "(pow(4, datum.Value) * exp(-4)) / factorial(datum.Value)",
              "as": "Probability"
            }
          ],
          "layer": [
            {
              "mark": {
                "type": "bar",
                "color": "red"
              },
              "height": 250,
              "width": 250,
              "encoding": {
                "x": {
                  "field": "Value",
                  "type": "quantitative",
                  "title": "Value"
                },
                "y": {
                  "field": "Probability",
                  "type": "quantitative",
                  "title": "Probability"
                }
              }
            }
          ]
        },
        {
          "title": [
            "Cumulative Mass Function (CMF) of",
            "Poisson Distribution (λ = 4)"
          ],
          "data": {
            "sequence": {
              "start": 0,
              "stop": 15,
              "step": 1,
              "as": "Value"
            }
          },
          "transform": [
            {
              "calculate": "(pow(4, datum.Value) * exp(-4)) / factorial(datum.Value)",
              "as": "Probability"
            },
            {
              "window": [
                {
                  "op": "sum",
                  "field": "Probability",
                  "as": "Cumulative"
                }
              ],
              "frame": [
                null,
                0
              ]
            }
          ],
          "layer": [
            {
              "mark": {
                "type": "line",
                "color": "purple"
              },
              "height": 250,
              "width": 250,
              "encoding": {
                "x": {
                  "field": "Value",
                  "type": "quantitative",
                  "title": "Value"
                },
                "y": {
                  "field": "Cumulative",
                  "type": "quantitative",
                  "title": "Cumulative Probability"
                }
              }
            }
          ]
        }
      ]
    }
  ]
}