<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>DecisionAnalytica Lab</title>
<link>https://lab.decisionanalytica.co.uk/notebook.html</link>
<atom:link href="https://lab.decisionanalytica.co.uk/notebook.xml" rel="self" type="application/rss+xml"/>
<description>Short technical entries: an idea, the code, the result.</description>
<generator>quarto-1.6.42</generator>
<lastBuildDate>Thu, 03 Dec 2026 00:00:00 GMT</lastBuildDate>
<item>
  <title>Where the data ends, judgement begins</title>
  <link>https://lab.decisionanalytica.co.uk/notebook/2026-12-03-welcome/</link>
  <description><![CDATA[ 




<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Illustrative example
</div>
</div>
<div class="callout-body-container callout-body">
<p>The numbers below are made up to show the method. No course or client data is used.</p>
</div>
</div>
<section id="the-question" class="level2">
<h2 class="anchored" data-anchor-id="the-question">The question</h2>
<p>A pharmacy manager hears that a supplier may have problems next month. Should they <strong>order extra stock now</strong>, or <strong>hold</strong>?</p>
<p>Data can tell us what each outcome is worth. It can’t tell us, on its own, how likely the supply shock is. That part is a judgement. Decision analysis makes that judgement explicit, so it can be discussed, challenged and improved.</p>
</section>
<section id="the-decision-written-down" class="level2">
<h2 class="anchored" data-anchor-id="the-decision-written-down">The decision, written down</h2>
<div id="setup" class="cell" data-execution_count="1">
<div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1">options <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> {</span>
<span id="cb1-2">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Order extra stock"</span>: {<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"shock"</span>: <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4200</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"no_shock"</span>: <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>},</span>
<span id="cb1-3">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hold"</span>:              {<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"shock"</span>: <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5000</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"no_shock"</span>: <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">800</span>},</span>
<span id="cb1-4">}</span>
<span id="cb1-5">p_shock <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># a stated judgement, not a measured fact</span></span>
<span id="cb1-6"></span>
<span id="cb1-7"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> expected_value(outcomes, p):</span>
<span id="cb1-8">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> outcomes[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"shock"</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> p) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> outcomes[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"no_shock"</span>]</span>
<span id="cb1-9"></span>
<span id="cb1-10"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> name, outcomes <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> options.items():</span>
<span id="cb1-11">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>name<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:&lt;18}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;"> EV = £</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>expected_value(outcomes, p_shock)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:,.0f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Order extra stock  EV = £600
Hold               EV = £-650</code></pre>
</div>
</div>
<p>At a 25% chance of a shock, ordering extra stock looks better. But the more useful question is a different one.</p>
</section>
<section id="how-sure-do-we-need-to-be" class="level2">
<h2 class="anchored" data-anchor-id="how-sure-do-we-need-to-be">How sure do we need to be?</h2>
<p>Instead of arguing about whether the chance is 20% or 30%, we can find the point where the decision flips.</p>
<div id="cell-fig-sensitivity" class="cell" data-execution_count="2">
<details class="code-fold">
<summary>Show the chart code</summary>
<div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> numpy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> np</span>
<span id="cb3-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.pyplot <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> plt</span>
<span id="cb3-3"></span>
<span id="cb3-4">plt.rcParams.update({<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"font.family"</span>: <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sans-serif"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"axes.spines.top"</span>: <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>,</span>
<span id="cb3-5">                     <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"axes.spines.right"</span>: <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"axes.edgecolor"</span>: <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#9AA6B0"</span>})</span>
<span id="cb3-6"></span>
<span id="cb3-7">p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.linspace(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>)</span>
<span id="cb3-8">order <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [expected_value(options[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Order extra stock"</span>], x) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> x <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> p]</span>
<span id="cb3-9">hold <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [expected_value(options[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hold"</span>], x) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> x <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> p]</span>
<span id="cb3-10"></span>
<span id="cb3-11">o, h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> options[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Order extra stock"</span>], options[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hold"</span>]</span>
<span id="cb3-12">crossover <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (h[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"no_shock"</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> o[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"no_shock"</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (</span>
<span id="cb3-13">    (o[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"shock"</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> o[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"no_shock"</span>]) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> (h[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"shock"</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> h[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"no_shock"</span>]))</span>
<span id="cb3-14"></span>
<span id="cb3-15">fig, ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.subplots(figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.8</span>))</span>
<span id="cb3-16">ax.plot(p, order, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0F5C6E"</span>, lw<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.2</span>, label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Order extra stock"</span>)</span>
<span id="cb3-17">ax.plot(p, hold, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#B5651D"</span>, lw<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.2</span>, label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Hold"</span>)</span>
<span id="cb3-18">ax.axhline(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#E2E6EA"</span>, lw<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb3-19">ax.axvline(crossover, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5E6B75"</span>, ls<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--"</span>, lw<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb3-20">ax.annotate(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f"Decision flips at p ≈ </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>crossover<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:.0%}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, xy<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(crossover, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb3-21">            xytext<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(crossover <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.02</span>, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1500</span>), color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#1E2A33"</span>,</span>
<span id="cb3-22">            arrowprops<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">dict</span>(arrowstyle<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-"</span>, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#5E6B75"</span>))</span>
<span id="cb3-23">ax.axvline(p_shock, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0F5C6E"</span>, lw<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, alpha<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">.35</span>)</span>
<span id="cb3-24">ax.text(p_shock <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.006</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1300</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"our judgement: 25%"</span>, color<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0F5C6E"</span>, fontsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>)</span>
<span id="cb3-25">ax.set_xlabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Judged chance of a supply shock"</span>)</span>
<span id="cb3-26">ax.set_ylabel(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Expected value (£)"</span>)</span>
<span id="cb3-27">ax.xaxis.set_major_formatter(plt.FuncFormatter(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">lambda</span> v, _: <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>v<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:.0%}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>))</span>
<span id="cb3-28">ax.yaxis.set_major_formatter(plt.FuncFormatter(<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">lambda</span> v, _: <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f"£</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>v<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:,.0f}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>))</span>
<span id="cb3-29">ax.legend(frameon<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>, loc<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"upper left"</span>)</span>
<span id="cb3-30">fig.tight_layout()</span>
<span id="cb3-31">fig.savefig(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"thumbnail.png"</span>, dpi<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span>)</span>
<span id="cb3-32">plt.show()</span></code></pre></div>
</details>
<div class="cell-output cell-output-display">
<div id="fig-sensitivity" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-fig figure">
<div aria-describedby="fig-sensitivity-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://lab.decisionanalytica.co.uk/notebook/2026-12-03-welcome/index_files/figure-html/fig-sensitivity-output-1.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-sensitivity-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: Expected value of each option as the judged chance of a supply shock changes. Left of the crossover, hold. Right of it, order.
</figcaption>
</figure>
</div>
</div>
</div>
<p>The decision flips at about a <strong>13%</strong> chance of a shock. So the team doesn’t need to agree on an exact number. They only need to agree that the risk is above roughly one in eight. That is a much easier, and much better, conversation to have before the crunch arrives.</p>
</section>
<section id="what-id-do-differently" class="level2">
<h2 class="anchored" data-anchor-id="what-id-do-differently">What I’d do differently</h2>
<ul>
<li>Replace the made-up values with real margins and holding costs.</li>
<li>Add a third option, such as a partial order, which often beats both extremes.</li>
<li>Ask several stakeholders for their own estimate of the chance, and show where they disagree.</li>
</ul>
</section>
<section id="why-this-matters" class="level2">
<h2 class="anchored" data-anchor-id="why-this-matters">Why this matters</h2>
<p>Data analytics gives us the values in the tree. Decision analysis gives us the conversation about the uncertainty. Together they tell us not just <em>what</em> to do, but <em>how confident we need to be</em>, and when to look again.</p>


</section>

 ]]></description>
  <category>decision analysis</category>
  <category>python</category>
  <category>method</category>
  <guid>https://lab.decisionanalytica.co.uk/notebook/2026-12-03-welcome/</guid>
  <pubDate>Thu, 03 Dec 2026 00:00:00 GMT</pubDate>
  <media:content url="https://lab.decisionanalytica.co.uk/notebook/2026-12-03-welcome/thumbnail.png" medium="image" type="image/png" height="78" width="144"/>
</item>
</channel>
</rss>
