{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "name": "Monte_Carlo_Sim_of_a_200_Year_Lifespan.ipynb",
      "authorship_tag": "ABX9TyM6OCSKL/PNHWype+qicrOW",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/OJB-Quantum/Monte-Carlo-Sim/blob/main/Monte_Carlo_Sim_of_a_200_Year_Lifespan.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "vMBDv-sv-StU",
        "outputId": "af571ffe-a4ac-4796-f2dc-c1e71750ddc4"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Ran 10000 simulations of a 200-year lifespan model.\n",
            "\n",
            "Average age of death: 120.22\n",
            "Average number of career changes: 4.22\n",
            "Average number of major illnesses: 1.61\n"
          ]
        }
      ],
      "source": [
        "import numpy as np\n",
        "import random\n",
        "import statistics\n",
        "\n",
        "def mortality_probability(age, max_age=200):\n",
        "    \"\"\"\n",
        "    A toy function that returns the probability of death at a given age.\n",
        "    The function is designed so that average lifespan hovers near 200,\n",
        "    but you can adjust it as needed.\n",
        "    \"\"\"\n",
        "    # Example: A small base rate, increasing with age.\n",
        "    # At age 0 --> prob ~ 0.0, at age 200 --> prob ~ 0.02\n",
        "    # This will lead to many individuals reaching 200,\n",
        "    # but is just a toy model. Tweak as necessary.\n",
        "    return 0.0001 * age\n",
        "\n",
        "def simulate_one_life(max_age=200):\n",
        "    \"\"\"\n",
        "    Simulate a single life path, returning:\n",
        "      - age of death (or 200 if still alive)\n",
        "      - record of 'career changes'\n",
        "      - record of 'major illnesses'\n",
        "    \"\"\"\n",
        "    current_age = 0\n",
        "    is_alive = True\n",
        "\n",
        "    career_change_years = []\n",
        "    illness_years = []\n",
        "\n",
        "    while is_alive and current_age <= max_age:\n",
        "        # Roll for mortality this year\n",
        "        death_chance = mortality_probability(current_age, max_age)\n",
        "        if random.random() < death_chance:\n",
        "            # Person dies this year\n",
        "            return current_age, career_change_years, illness_years\n",
        "\n",
        "        # If still alive, check for events:\n",
        "        # 1) Career change (example ages 25-150, 5% chance each year)\n",
        "        if 25 <= current_age <= 150:\n",
        "            if random.random() < 0.05:\n",
        "                career_change_years.append(current_age)\n",
        "\n",
        "        # 2) Major illness (example ages 40-190, 2% chance each year)\n",
        "        if 40 <= current_age <= 190:\n",
        "            if random.random() < 0.02:\n",
        "                illness_years.append(current_age)\n",
        "\n",
        "        current_age += 1\n",
        "\n",
        "    # If we exited the loop without dying, it means we reached max_age\n",
        "    return max_age, career_change_years, illness_years\n",
        "\n",
        "\n",
        "def run_simulation(num_simulations=10000, max_age=200):\n",
        "    \"\"\"\n",
        "    Run multiple simulations and return:\n",
        "     - distribution of death ages\n",
        "     - average age of death\n",
        "     - average number of career changes\n",
        "     - average number of major illnesses\n",
        "    \"\"\"\n",
        "    death_ages = []\n",
        "    career_change_counts = []\n",
        "    illness_counts = []\n",
        "\n",
        "    for _ in range(num_simulations):\n",
        "        death_age, career_changes, illnesses = simulate_one_life(max_age)\n",
        "        death_ages.append(death_age)\n",
        "        career_change_counts.append(len(career_changes))\n",
        "        illness_counts.append(len(illnesses))\n",
        "\n",
        "    avg_death_age = statistics.mean(death_ages)\n",
        "    avg_career_changes = statistics.mean(career_change_counts)\n",
        "    avg_illnesses = statistics.mean(illness_counts)\n",
        "\n",
        "    results = {\n",
        "        \"avg_death_age\": avg_death_age,\n",
        "        \"avg_career_changes\": avg_career_changes,\n",
        "        \"avg_illnesses\": avg_illnesses,\n",
        "        \"death_age_distribution\": death_ages\n",
        "    }\n",
        "    return results\n",
        "\n",
        "# -----------------------\n",
        "# Run the simulation\n",
        "# -----------------------\n",
        "if __name__ == \"__main__\":\n",
        "    np.random.seed(42)  # For reproducibility (optional)\n",
        "    random.seed(42)\n",
        "\n",
        "    N = 10_000\n",
        "    simulation_results = run_simulation(num_simulations=N, max_age=200)\n",
        "\n",
        "    print(f\"Ran {N} simulations of a 200-year lifespan model.\\n\")\n",
        "    print(f\"Average age of death: {simulation_results['avg_death_age']:.2f}\")\n",
        "    print(f\"Average number of career changes: {simulation_results['avg_career_changes']:.2f}\")\n",
        "    print(f\"Average number of major illnesses: {simulation_results['avg_illnesses']:.2f}\")\n",
        "    # You could also plot or further analyze death_age_distribution if desired."
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import numpy as np\n",
        "import random\n",
        "import statistics\n",
        "import plotly.graph_objects as go\n",
        "from collections import Counter\n",
        "\n",
        "# ----------------------\n",
        "# Step 1: Define the simulation\n",
        "# ----------------------\n",
        "def mortality_probability(age, max_age=200):\n",
        "    return 0.0001 * age\n",
        "\n",
        "def simulate_one_life(max_age=200):\n",
        "    current_age = 0\n",
        "    career_change_years = []\n",
        "    illness_years = []\n",
        "\n",
        "    while current_age <= max_age:\n",
        "        death_chance = mortality_probability(current_age, max_age)\n",
        "        if random.random() < death_chance:\n",
        "            return current_age, career_change_years, illness_years\n",
        "\n",
        "        if 25 <= current_age <= 150:\n",
        "            if random.random() < 0.05:\n",
        "                career_change_years.append(current_age)\n",
        "        if 40 <= current_age <= 190:\n",
        "            if random.random() < 0.02:\n",
        "                illness_years.append(current_age)\n",
        "\n",
        "        current_age += 1\n",
        "    return max_age, career_change_years, illness_years\n",
        "\n",
        "def run_simulation(num_simulations=10000, max_age=200):\n",
        "    death_ages = []\n",
        "    career_change_counts = []\n",
        "    illness_counts = []\n",
        "\n",
        "    for _ in range(num_simulations):\n",
        "        d_age, c_changes, i_ills = simulate_one_life(max_age)\n",
        "        death_ages.append(d_age)\n",
        "        career_change_counts.append(len(c_changes))\n",
        "        illness_counts.append(len(i_ills))\n",
        "\n",
        "    results = {\n",
        "        \"death_ages\": death_ages,\n",
        "        \"career_change_counts\": career_change_counts,\n",
        "        \"illness_counts\": illness_counts\n",
        "    }\n",
        "    return results\n",
        "\n",
        "# ----------------------\n",
        "# Step 2: Binning functions\n",
        "# ----------------------\n",
        "def bin_career_changes(count):\n",
        "    if count == 0:\n",
        "        return \"Career=0\"\n",
        "    elif count == 1:\n",
        "        return \"Career=1\"\n",
        "    elif count == 2:\n",
        "        return \"Career=2\"\n",
        "    else:\n",
        "        return \"Career=3+\"\n",
        "\n",
        "def bin_illnesses(count):\n",
        "    if count == 0:\n",
        "        return \"Ill=0\"\n",
        "    elif count == 1:\n",
        "        return \"Ill=1\"\n",
        "    elif count == 2:\n",
        "        return \"Ill=2\"\n",
        "    else:\n",
        "        return \"Ill=3+\"\n",
        "\n",
        "def bin_death_age(age):\n",
        "    if age <= 50:\n",
        "        return \"Age=0-50\"\n",
        "    elif age <= 100:\n",
        "        return \"Age=51-100\"\n",
        "    elif age <= 150:\n",
        "        return \"Age=101-150\"\n",
        "    else:\n",
        "        return \"Age=151-200\"\n",
        "\n",
        "# ----------------------\n",
        "# Step 3: Build flow counters\n",
        "# ----------------------\n",
        "def build_flow_counts(results):\n",
        "    career_counts = results[\"career_change_counts\"]\n",
        "    illness_counts = results[\"illness_counts\"]\n",
        "    death_ages = results[\"death_ages\"]\n",
        "\n",
        "    from collections import Counter\n",
        "    combos = []\n",
        "\n",
        "    # Build the list of (career_bin, ill_bin, age_bin)\n",
        "    for c_count, i_count, d_age in zip(career_counts, illness_counts, death_ages):\n",
        "        c_bin = bin_career_changes(c_count)\n",
        "        i_bin = bin_illnesses(i_count)\n",
        "        a_bin = bin_death_age(d_age)\n",
        "        combos.append((c_bin, i_bin, a_bin))\n",
        "\n",
        "    combo_counter = Counter(combos)\n",
        "\n",
        "    flow1_counter = Counter()  # (career_bin -> ill_bin)\n",
        "    flow2_counter = Counter()  # (ill_bin -> age_bin)\n",
        "\n",
        "    for (c_bin, i_bin, a_bin), count in combo_counter.items():\n",
        "        flow1_counter[(c_bin, i_bin)] += count\n",
        "        flow2_counter[(i_bin, a_bin)] += count\n",
        "\n",
        "    return flow1_counter, flow2_counter\n",
        "\n",
        "# ----------------------\n",
        "# Step 4: Convert counters -> Sankey format\n",
        "# ----------------------\n",
        "def build_sankey_data(flow1_counter, flow2_counter):\n",
        "    career_bins = [\"Career=0\", \"Career=1\", \"Career=2\", \"Career=3+\"]\n",
        "    illness_bins = [\"Ill=0\", \"Ill=1\", \"Ill=2\", \"Ill=3+\"]\n",
        "    age_bins = [\"Age=0-50\", \"Age=51-100\", \"Age=101-150\", \"Age=151-200\"]\n",
        "\n",
        "    all_nodes = career_bins + illness_bins + age_bins\n",
        "    label_to_index = {label: i for i, label in enumerate(all_nodes)}\n",
        "\n",
        "    source_list = []\n",
        "    target_list = []\n",
        "    value_list = []\n",
        "\n",
        "    # (career -> illness)\n",
        "    for (c_bin, i_bin), val in flow1_counter.items():\n",
        "        source_list.append(label_to_index[c_bin])\n",
        "        target_list.append(label_to_index[i_bin])\n",
        "        value_list.append(val)\n",
        "\n",
        "    # (illness -> age)\n",
        "    for (i_bin, a_bin), val in flow2_counter.items():\n",
        "        source_list.append(label_to_index[i_bin])\n",
        "        target_list.append(label_to_index[a_bin])\n",
        "        value_list.append(val)\n",
        "\n",
        "    return all_nodes, source_list, target_list, value_list\n",
        "\n",
        "# ----------------------\n",
        "# Step 5: Plot with Plotly\n",
        "# ----------------------\n",
        "def plot_sankey(all_nodes, source_list, target_list, value_list, title=\"Life Simulation Sankey\"):\n",
        "    fig = go.Figure(data=[go.Sankey(\n",
        "        node=dict(\n",
        "            pad=15,\n",
        "            thickness=20,\n",
        "            line=dict(color=\"black\", width=0.5),\n",
        "            label=all_nodes\n",
        "        ),\n",
        "        link=dict(\n",
        "            source=source_list,\n",
        "            target=target_list,\n",
        "            value=value_list\n",
        "        )\n",
        "    )])\n",
        "    fig.update_layout(title_text=title, font_size=12)\n",
        "    fig.show()\n",
        "\n",
        "# ----------------------\n",
        "# Main execution\n",
        "# ----------------------\n",
        "if __name__ == \"__main__\":\n",
        "    # For reproducibility (optional)\n",
        "    np.random.seed(42)\n",
        "    random.seed(42)\n",
        "\n",
        "    # 1) Run the simulation\n",
        "    results = run_simulation(num_simulations=10000, max_age=200)\n",
        "\n",
        "    # 2) Build the flow counters (career->illness, illness->death_age)\n",
        "    flow1_counter, flow2_counter = build_flow_counts(results)\n",
        "\n",
        "    # 3) Convert to Sankey data\n",
        "    all_nodes, source_list, target_list, value_list = build_sankey_data(flow1_counter, flow2_counter)\n",
        "\n",
        "    # 4) Plot Sankey\n",
        "    plot_sankey(all_nodes, source_list, target_list, value_list,\n",
        "                title=\"Monte Carlo Life Simulation (200-year span) - Sankey Diagram\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 542
        },
        "id": "h5Ei77Vb_LZf",
        "outputId": "3f0dc28c-c770-4d7c-ca05-4d4c1f380230"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script charset=\"utf-8\" src=\"https://cdn.plot.ly/plotly-2.35.2.min.js\"></script>                <div id=\"715802d9-578c-4cf1-8cde-2a8f950545d8\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"715802d9-578c-4cf1-8cde-2a8f950545d8\")) {                    Plotly.newPlot(                        \"715802d9-578c-4cf1-8cde-2a8f950545d8\",                        [{\"link\":{\"source\":[1,3,3,3,3,0,0,2,2,1,1,2,1,2,0,0,4,7,4,4,6,5,7,6,5,4,6,5,5,7,6],\"target\":[4,7,4,6,5,5,4,6,4,5,7,5,6,7,6,7,9,11,8,11,10,10,10,11,9,10,9,11,8,9,8],\"value\":[592,2384,1299,1549,1710,105,882,147,463,207,50,321,100,149,32,10,1394,1757,1128,204,706,889,711,791,917,510,327,488,49,125,4]},\"node\":{\"label\":[\"Career=0\",\"Career=1\",\"Career=2\",\"Career=3+\",\"Ill=0\",\"Ill=1\",\"Ill=2\",\"Ill=3+\",\"Age=0-50\",\"Age=51-100\",\"Age=101-150\",\"Age=151-200\"],\"line\":{\"color\":\"black\",\"width\":0.5},\"pad\":15,\"thickness\":20},\"type\":\"sankey\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"title\":{\"text\":\"Monte Carlo Life Simulation (200-year span) - Sankey Diagram\"},\"font\":{\"size\":12}},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('715802d9-578c-4cf1-8cde-2a8f950545d8');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {}
        }
      ]
    }
  ]
}