Files
maths-cs-ai-compendium-zh/images/conditional_probability.svg
T

47 lines
2.4 KiB
XML

<svg width="700" height="300" xmlns="http://www.w3.org/2000/svg">
<text x="350" y="25" fill="#333" font-size="14" font-weight="bold" text-anchor="middle">Conditional Probability: P(A | B)</text>
<!-- Left: full sample space -->
<text x="175" y="50" fill="#666" font-size="12" text-anchor="middle">Full sample space S</text>
<rect x="30" y="60" width="290" height="200" rx="6" fill="#f5f5f5" stroke="#333" stroke-width="1.2"/>
<circle cx="140" cy="160" r="70" fill="#e74c3c" opacity="0.2" stroke="#e74c3c" stroke-width="1.5"/>
<text x="105" y="145" fill="#e74c3c" font-size="12">A</text>
<circle cx="210" cy="160" r="70" fill="#3498db" opacity="0.2" stroke="#3498db" stroke-width="1.5"/>
<text x="245" y="145" fill="#3498db" font-size="12">B</text>
<clipPath id="clipA2">
<circle cx="140" cy="160" r="70"/>
</clipPath>
<circle cx="210" cy="160" r="70" fill="#9b59b6" opacity="0.3" clip-path="url(#clipA2)"/>
<text x="175" y="165" fill="#9b59b6" font-size="10" text-anchor="middle">A∩B</text>
<!-- Arrow -->
<text x="365" y="140" fill="#333" font-size="12" text-anchor="middle">Given B</text>
<text x="365" y="158" fill="#333" font-size="12" text-anchor="middle">occurred</text>
<line x1="335" y1="165" x2="395" y2="165" stroke="#333" stroke-width="1.5" marker-end="url(#arrow2)"/>
<defs>
<marker id="arrow2" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto">
<polygon points="0 0, 8 3, 0 6" fill="#333"/>
</marker>
</defs>
<!-- Right: shrunk sample space -->
<text x="540" y="50" fill="#666" font-size="12" text-anchor="middle">New sample space = B</text>
<!-- B becomes the whole space -->
<circle cx="540" cy="160" r="90" fill="#3498db" opacity="0.15" stroke="#3498db" stroke-width="2"/>
<text x="590" y="105" fill="#3498db" font-size="12">B</text>
<!-- A∩B highlighted inside -->
<ellipse cx="510" cy="160" rx="45" ry="55" fill="#9b59b6" opacity="0.35" stroke="#9b59b6" stroke-width="1.5"/>
<text x="510" y="155" fill="#9b59b6" font-size="11" text-anchor="middle" font-weight="bold">A ∩ B</text>
<!-- Not A part of B -->
<text x="570" y="180" fill="#3498db" font-size="10" text-anchor="middle">B \ A</text>
<!-- Bottom formula -->
<text x="350" y="288" fill="#333" font-size="13" text-anchor="middle">P(A | B) = P(A ∩ B) / P(B)</text>
<text x="350" y="270" fill="#666" font-size="11" text-anchor="middle">The fraction of B that also belongs to A</text>
</svg>