<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ajiaxi</title>
    <description>The latest articles on DEV Community by Ajiaxi (@ajiaxi).</description>
    <link>https://dev.to/ajiaxi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4102869%2F451e472f-8192-4f85-a28a-0723066cfa85.png</url>
      <title>DEV Community: Ajiaxi</title>
      <link>https://dev.to/ajiaxi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ajiaxi"/>
    <language>en</language>
    <item>
      <title>Drawing Probability Trees by Hand Is Annoying, So I Built This</title>
      <dc:creator>Ajiaxi</dc:creator>
      <pubDate>Mon, 31 Aug 2026 14:15:07 +0000</pubDate>
      <link>https://dev.to/ajiaxi/drawing-probability-trees-by-hand-is-annoying-so-i-built-this-hpo</link>
      <guid>https://dev.to/ajiaxi/drawing-probability-trees-by-hand-is-annoying-so-i-built-this-hpo</guid>
      <description>&lt;p&gt;Probability trees look simple.&lt;/p&gt;

&lt;p&gt;You start with an event, add a few branches, write probabilities next to them, and calculate the probability of each path.&lt;/p&gt;

&lt;p&gt;Easy, right?&lt;/p&gt;

&lt;p&gt;That was what I thought too.&lt;/p&gt;

&lt;p&gt;Then I started thinking about what it would take to generate a probability tree automatically from something like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A bag contains 5 red balls and 3 blue balls. Two balls are drawn without replacement.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Suddenly, it was no longer just a drawing problem.&lt;/p&gt;

&lt;p&gt;The system needs to understand the scenario, identify events and outcomes, calculate conditional probabilities, validate the math, position the nodes, and still make the result easy to edit.&lt;/p&gt;

&lt;p&gt;That experiment eventually became &lt;strong&gt;&lt;a href="https://probpath.com/" rel="noopener noreferrer"&gt;ProbPath&lt;/a&gt;&lt;/strong&gt;, a browser-based probability tree generator.&lt;/p&gt;

&lt;p&gt;But building it taught me a few things that turned out to be much more interesting than simply drawing a tree.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Natural language is messy
&lt;/h2&gt;

&lt;p&gt;A probability engine would probably prefer input like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;P(Red) = 5/8
P(Blue) = 3/8

P(Red | Red first) = 4/7
P(Blue | Red first) = 3/7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unfortunately, humans usually don't describe probability problems like that.&lt;/p&gt;

&lt;p&gt;They write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;There are 5 red balls and 3 blue balls in a bag.
Two balls are drawn without replacement.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A test has 95% sensitivity, a 5% false positive rate,
and the disease prevalence is 1%.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So before generating any visualization, the first problem is turning natural language into a structured probability model.&lt;/p&gt;

&lt;p&gt;Conceptually, the result might look something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"event"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"First draw"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"outcomes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"label"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Red"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"probability"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0.625&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"label"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Blue"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"probability"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0.375&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For dependent events, each branch may then contain a different set of next-step probabilities.&lt;/p&gt;

&lt;p&gt;This distinction matters because the tree is not just visual decoration.&lt;/p&gt;

&lt;p&gt;The structure determines the math.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. I don't want AI to be the source of truth for the math
&lt;/h2&gt;

&lt;p&gt;One design principle became important very quickly:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Use AI to understand the problem. Use deterministic code to calculate the probabilities.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;An AI model is useful for interpreting what the user means.&lt;/p&gt;

&lt;p&gt;For example, it can recognize that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Draw two balls without replacement
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;means the second probability depends on what happened during the first draw.&lt;/p&gt;

&lt;p&gt;But once the structure is understood, calculations such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5/8 × 3/7 = 15/56
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;should not need to depend on an AI model guessing the answer correctly.&lt;/p&gt;

&lt;p&gt;The same applies to validation.&lt;/p&gt;

&lt;p&gt;If a node has three outgoing branches:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A = 0.4
B = 0.3
C = 0.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the application should immediately know something is wrong because:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0.4 + 0.3 + 0.4 = 1.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That kind of validation is deterministic.&lt;/p&gt;

&lt;p&gt;This led to a simple separation of responsibilities:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Natural language
      ↓
AI interpretation
      ↓
Structured probability model
      ↓
Deterministic calculation
      ↓
Validation
      ↓
Visualization
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I like this pattern beyond probability tools too.&lt;/p&gt;

&lt;p&gt;AI can be very useful at the fuzzy boundary where humans express intent.&lt;/p&gt;

&lt;p&gt;Once the intent has been converted into structured data, traditional software is often still the better tool for enforcing rules.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Drawing the tree was harder than I expected
&lt;/h2&gt;

&lt;p&gt;A two-level tree is easy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;           Start
          /     \
        Red     Blue
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problem appears when the tree grows.&lt;/p&gt;

&lt;p&gt;Imagine something closer to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Start
├── A
│   ├── A1
│   ├── A2
│   └── A3
├── B
│   ├── B1
│   └── B2
└── C
    ├── C1
    ├── C2
    ├── C3
    └── C4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the visualization needs to answer several questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How much vertical space should each subtree receive?&lt;/li&gt;
&lt;li&gt;How far apart should parent and child nodes be?&lt;/li&gt;
&lt;li&gt;How do you avoid overlapping labels?&lt;/li&gt;
&lt;li&gt;What happens when one branch becomes much deeper than the others?&lt;/li&gt;
&lt;li&gt;How should the layout change when the user adds another outcome?&lt;/li&gt;
&lt;li&gt;How much should the canvas expand before the tree becomes difficult to navigate?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At that point, I realized that a probability tree generator is partly a graph-layout problem.&lt;/p&gt;

&lt;p&gt;Rendering lines and boxes is easy.&lt;/p&gt;

&lt;p&gt;Deciding where they should go is the interesting part.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Generation shouldn't be the final state
&lt;/h2&gt;

&lt;p&gt;My first mental model for the product was basically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Describe problem
      ↓
Generate tree
      ↓
Done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But that isn't how people actually work.&lt;/p&gt;

&lt;p&gt;Users want to generate something and then change it.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Flip a fair coin twice.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;might generate the first version of a tree.&lt;/p&gt;

&lt;p&gt;Then the user might decide:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Actually, make the coin 70% likely to land heads.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or they might want to rename an outcome, add another stage, delete a branch, or change a probability directly.&lt;/p&gt;

&lt;p&gt;So the workflow became closer to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Describe
   ↓
Generate
   ↓
Edit
   ↓
Recalculate
   ↓
Validate
   ↓
Export
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That changed how I thought about the product.&lt;/p&gt;

&lt;p&gt;AI generation is useful for removing the blank page.&lt;/p&gt;

&lt;p&gt;But the generated result still needs to behave like normal software.&lt;/p&gt;

&lt;p&gt;It needs to be editable.&lt;/p&gt;




&lt;h2&gt;
  
  
  A few probability problems I use for testing
&lt;/h2&gt;

&lt;p&gt;Simple examples are useful, but the more interesting cases are the ones where the probability changes along the tree.&lt;/p&gt;

&lt;h3&gt;
  
  
  Coin flips
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Flip a fair coin twice.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the easiest sanity check.&lt;/p&gt;

&lt;p&gt;Each branch should remain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Heads = 0.5
Tails = 0.5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and each final path should have probability:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0.5 × 0.5 = 0.25
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Drawing without replacement
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A bag contains 5 red balls and 3 blue balls.
Draw two balls without replacement.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first event is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Red = 5/8
Blue = 3/8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But after drawing red, the next event becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Red = 4/7
Blue = 3/7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After drawing blue:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Red = 5/7
Blue = 2/7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is where probability trees become particularly useful because the diagram makes conditional probabilities much easier to follow.&lt;/p&gt;




&lt;h3&gt;
  
  
  Medical testing
&lt;/h3&gt;

&lt;p&gt;Another good example is Bayes-style problems.&lt;/p&gt;

&lt;p&gt;Suppose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Disease prevalence = 1%
Sensitivity = 95%
False positive rate = 5%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A common intuition is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If the test is 95% accurate and I test positive, I must have around a 95% chance of having the disease.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But that's not what the numbers imply.&lt;/p&gt;

&lt;p&gt;A probability tree makes the base-rate effect much easier to see visually.&lt;/p&gt;

&lt;p&gt;This is one of the reasons I like probability trees: they are not only calculation tools.&lt;/p&gt;

&lt;p&gt;They are reasoning tools.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I ended up building
&lt;/h2&gt;

&lt;p&gt;The experiment became &lt;strong&gt;ProbPath&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It lets you describe a probability scenario in natural language and turn it into a visual probability tree.&lt;/p&gt;

&lt;p&gt;From there, the tree can be edited and recalculated rather than treated as a static AI-generated image.&lt;/p&gt;

&lt;p&gt;You can try it here:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://probpath.com/" rel="noopener noreferrer"&gt;https://probpath.com/&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The main goal is pretty simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Make probability trees faster to create without hiding the underlying math.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I'm also experimenting with more traditional manual tools for people who prefer building the tree themselves instead of starting with AI.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;A few ideas from this project have stuck with me.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Let AI interpret. Let code calculate.
&lt;/h3&gt;

&lt;p&gt;Natural language understanding is fuzzy.&lt;/p&gt;

&lt;p&gt;Probability rules are not.&lt;/p&gt;

&lt;p&gt;Separating the two makes the system easier to reason about and easier to validate.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Generated interfaces still need to be editable.
&lt;/h3&gt;

&lt;p&gt;Generation is great for getting from zero to one.&lt;/p&gt;

&lt;p&gt;But users still need control after generation.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Visualization problems often become layout problems.
&lt;/h3&gt;

&lt;p&gt;The hardest part wasn't drawing nodes and branches.&lt;/p&gt;

&lt;p&gt;It was deciding where everything should go as the tree changes.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Small educational tools can hide interesting engineering problems.
&lt;/h3&gt;

&lt;p&gt;A probability tree generator sounds like a very small application.&lt;/p&gt;

&lt;p&gt;But once you combine natural-language parsing, structured data, mathematical validation, graph layout, editing, and export, there are quite a few interesting problems inside it.&lt;/p&gt;




&lt;p&gt;I'm still working on ProbPath and experimenting with better ways to handle larger trees, conditional probability, and more advanced probability problems.&lt;/p&gt;

&lt;p&gt;If you've built graph editors, diagramming tools, math visualizations, or AI-to-structured-data workflows, I'd be interested to hear how you approached similar problems.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>webdev</category>
      <category>ai</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
