Follow ______ on twitter.

3.3.3 Poisson Distribution

Code

Vega-Lite Chart

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "Poisson Distribution PMF for different lambda values",
  "data": {
    "sequence": {
      "start": 0,
      "stop": 20,
      "step": 1,
      "as": "k"
    }
  },
  "transform": [
    {
      "calculate": "exp(-2) * pow(2, datum.k) / factorial(datum.k)",
      "as": "y1"
    },
    {
      "calculate": "exp(-5) * pow(5, datum.k) / factorial(datum.k)",
      "as": "y2"
    },
    {
      "calculate": "exp(-10) * pow(10, datum.k) / factorial(datum.k)",
      "as": "y3"
    }
  ],
  "hconcat": [
    {
      "width": 250,
      "height": 200,
      "title": "λ = 2",
      "mark": "bar",
      "encoding": {
        "x": {
          "field": "k",
          "type": "ordinal",
          "title": "Number of Events"
        },
        "y": {
          "field": "y1",
          "type": "quantitative",
          "title": "Probability"
        },
        "color": {
          "value": "#004976"
        }
      }
    },
    {
      "width": 250,
      "height": 200,
      "title": "λ = 5",
      "mark": "bar",
      "encoding": {
        "x": {
          "field": "k",
          "type": "ordinal",
          "title": "Number of Events"
        },
        "y": {
          "field": "y2",
          "type": "quantitative",
          "title": "Probability"
        },
        "color": {
          "value": "#7A0045"
        }
      }
    },
    {
      "width": 250,
      "height": 200,
      "title": "λ = 10",
      "mark": "bar",
      "encoding": {
        "x": {
          "field": "k",
          "type": "ordinal",
          "title": "Number of Events"
        },
        "y": {
          "field": "y3",
          "type": "quantitative",
          "title": "Probability"
        },
        "color": {
          "value": "#486300"
        }
      }
    }
  ]
}