marimo-learn / _site /probability /06_probability_of_and.html
Haleshot's picture
changes
5d38ada unverified
raw
history blame
20.8 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="./favicon.ico" />
<!-- Preload is necessary because we show these images when we disconnect from the server,
but at that point we cannot load these images from the server -->
<link rel="preload" href="./assets/gradient-yHQUC_QB.png" as="image" />
<link rel="preload" href="./assets/noise-60BoTA8O.png" as="image" />
<!-- Preload the fonts -->
<link rel="preload" href="./assets/Lora-VariableFont_wght-B2ootaw-.ttf" as="font" crossorigin="anonymous" />
<link rel="preload" href="./assets/PTSans-Regular-CxL0S8W7.ttf" as="font" crossorigin="anonymous" />
<link rel="preload" href="./assets/PTSans-Bold-D9fedIX3.ttf" as="font" crossorigin="anonymous" />
<link rel="preload" href="./assets/FiraMono-Regular-BTCkDNvf.ttf" as="font" crossorigin="anonymous" />
<link rel="preload" href="./assets/FiraMono-Medium-DU3aDxX5.ttf" as="font" crossorigin="anonymous" />
<link rel="preload" href="./assets/FiraMono-Bold-CLVRCuM9.ttf" as="font" crossorigin="anonymous" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="a marimo app" />
<link rel="apple-touch-icon" href="./apple-touch-icon.png" />
<link rel="manifest" href="./manifest.json" />
<script data-marimo="true">
function __resizeIframe(obj) {
var scrollbarHeight = 20; // Max between windows, mac, and linux
function setHeight() {
var element = obj.contentWindow.document.documentElement;
// If there is no vertical scrollbar, we don't need to resize the iframe
if (element.scrollHeight === element.clientHeight) {
return;
}
// Create a new height that includes the scrollbar height if it's visible
var hasHorizontalScrollbar = element.scrollWidth > element.clientWidth;
var newHeight = element.scrollHeight + (hasHorizontalScrollbar ? scrollbarHeight : 0);
// Only update the height if it's different from the current height
if (obj.style.height !== `${newHeight}px`) {
obj.style.height = `${newHeight}px`;
}
}
// Resize the iframe to the height of the content and bottom scrollbar height
setHeight();
// Resize the iframe when the content changes
const resizeObserver = new ResizeObserver((entries) => {
setHeight();
});
resizeObserver.observe(obj.contentWindow.document.body);
}
</script>
<marimo-filename hidden>notebook.py</marimo-filename>
<marimo-mode data-mode='edit' hidden></marimo-mode>
<marimo-version data-version='0.11.9' hidden></marimo-version>
<marimo-user-config data-config='{"completion": {"activate_on_typing": true, "copilot": false}, "display": {"theme": "light", "code_editor_font_size": 14, "default_width": "medium", "dataframes": "rich", "cell_output": "above"}, "formatting": {"line_length": 79}, "keymap": {"preset": "default", "overrides": {}}, "runtime": {"auto_instantiate": true, "auto_reload": "off", "on_cell_change": "autorun", "watcher_on_save": "lazy", "output_max_bytes": 8000000, "std_stream_max_bytes": 1000000}, "save": {"autosave": "off", "autosave_delay": 1000, "format_on_save": false}, "package_management": {"manager": "pip"}, "server": {"browser": "default", "follow_symlink": false}, "snippets": {"custom_paths": [], "include_default_snippets": true}}' data-overrides='{}' hidden></marimo-user-config>
<marimo-app-config data-config='{"width": "medium"}' hidden></marimo-app-config>
<marimo-server-token data-token='123' hidden></marimo-server-token>
<title>06 probability of and</title>
<script type="module" crossorigin src="./assets/index-BiV-b1K2.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-DkqMrX_B.css">
<marimo-wasm hidden=""></marimo-wasm>
<script>
if (window.location.protocol === 'file:') {
alert('Warning: This file must be served by an HTTP server to function correctly.');
}
</script>
<style>
#save-button {
display: none !important;
}
#filename-input {
display: none !important;
}
</style>
<marimo-code hidden="" data-show-code="false">import%20marimo%0A%0A__generated_with%20%3D%20%220.11.9%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%20%20%20%20from%20matplotlib_venn%20import%20venn2%0A%20%20%20%20return%20plt%2C%20venn2%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%20%20%20%20%23%20Probability%20of%20And%0A%20%20%20%20%20%20%20%20_This%20notebook%20is%20a%20computational%20companion%20to%20the%20book%20%5B%22Probability%20for%20Computer%20Scientists%22%5D(https%3A%2F%2Fchrispiech.github.io%2FprobabilityForComputerScientists%2Fen%2Fpart1%2Fprob_and%2F)%2C%20by%20Stanford%20professor%20Chris%20Piech._%0A%0A%20%20%20%20%20%20%20%20When%20calculating%20the%20probability%20of%20both%20events%20occurring%20together%2C%20we%20need%20to%20consider%20whether%20the%20events%20are%20independent%20or%20dependent.%0A%20%20%20%20%20%20%20%20Let's%20explore%20how%20to%20calculate%20%24P(E%20%5Ccap%20F)%24%2C%20i.e.%20%24P(E%20%5Ctext%7B%20and%20%7D%20F)%24%2C%20in%20different%20scenarios.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%20%20%20%20%23%23%20And%20with%20Independent%20Events%0A%0A%20%20%20%20%20%20%20%20Two%20events%20%24E%24%20and%20%24F%24%20are%20**independent**%20if%20knowing%20one%20event%20occurred%20doesn't%20affect%20the%20probability%20of%20the%20other.%20%0A%20%20%20%20%20%20%20%20For%20independent%20events%3A%0A%0A%20%20%20%20%20%20%20%20%24P(E%20%5Ctext%7B%20and%20%7D%20F)%20%3D%20P(E)%20%5Ccdot%20P(F)%24%0A%0A%20%20%20%20%20%20%20%20For%20example%3A%0A%0A%20%20%20%20%20%20%20%20-%20Rolling%20a%206%20on%20one%20die%20and%20getting%20heads%20on%20a%20coin%20flip%0A%20%20%20%20%20%20%20%20-%20Drawing%20a%20heart%20from%20a%20deck%2C%20replacing%20it%2C%20and%20drawing%20another%20heart%0A%20%20%20%20%20%20%20%20-%20Getting%20a%20computer%20error%20on%20Monday%20vs.%20Tuesday%0A%0A%20%20%20%20%20%20%20%20Here's%20a%20Python%20function%20to%20calculate%20probability%20for%20independent%20events%3A%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20def%20calc_independent_prob(p_e%2C%20p_f)%3A%0A%20%20%20%20%20%20%20%20return%20p_e%20*%20p_f%0A%0A%20%20%20%20%23%20Example%201%3A%20Rolling%20a%20die%20and%20flipping%20a%20coin%0A%20%20%20%20p_six%20%3D%201%2F6%20%20%20%20%20%20%20%20%20%20%20%23%20P(rolling%20a%206)%0A%20%20%20%20p_heads%20%3D%201%2F2%20%20%20%20%20%20%20%20%20%23%20P(getting%20heads)%0A%20%20%20%20p_both%20%3D%20calc_independent_prob(p_six%2C%20p_heads)%0A%20%20%20%20print(f%22Example%201%3A%20P(rolling%206%20AND%20getting%20heads)%20%3D%20%7Bp_six%3A.3f%7D%20%C3%97%20%7Bp_heads%3A.3f%7D%20%3D%20%7Bp_both%3A.3f%7D%22)%0A%20%20%20%20return%20calc_independent_prob%2C%20p_both%2C%20p_heads%2C%20p_six%0A%0A%0A%40app.cell%0Adef%20_(calc_independent_prob)%3A%0A%20%20%20%20%23%20Example%202%3A%20Two%20independent%20system%20components%20failing%0A%20%20%20%20p_cpu_fail%20%3D%200.05%20%20%20%20%20%23%20P(CPU%20failure)%0A%20%20%20%20p_disk_fail%20%3D%200.03%20%20%20%20%23%20P(disk%20failure)%0A%20%20%20%20p_both_fail%20%3D%20calc_independent_prob(p_cpu_fail%2C%20p_disk_fail)%0A%20%20%20%20print(f%22Example%202%3A%20P(both%20CPU%20and%20disk%20failing)%20%3D%20%7Bp_cpu_fail%3A.3f%7D%20%C3%97%20%7Bp_disk_fail%3A.3f%7D%20%3D%20%7Bp_both_fail%3A.3f%7D%22)%0A%20%20%20%20return%20p_both_fail%2C%20p_cpu_fail%2C%20p_disk_fail%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%20%20%20%20%23%23%20And%20with%20Dependent%20Events%0A%0A%20%20%20%20%20%20%20%20For%20dependent%20events%2C%20we%20use%20the%20**chain%20rule**%3A%0A%0A%20%20%20%20%20%20%20%20%24P(E%20%5Ctext%7B%20and%20%7D%20F)%20%3D%20P(E)%20%5Ccdot%20P(F%7CE)%24%0A%0A%20%20%20%20%20%20%20%20where%20%24P(F%7CE)%24%20is%20the%20probability%20of%20%24F%24%20occurring%20given%20that%20%24E%24%20has%20occurred.%0A%0A%20%20%20%20%20%20%20%20For%20example%3A%0A%0A%20%20%20%20%20%20%20%20-%20Drawing%20two%20hearts%20without%20replacement%0A%20%20%20%20%20%20%20%20-%20Getting%20two%20consecutive%20heads%20in%20poker%0A%20%20%20%20%20%20%20%20-%20System%20failures%20in%20connected%20components%0A%0A%20%20%20%20%20%20%20%20Let's%20implement%20this%20calculation%3A%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20def%20calc_dependent_prob(p_e%2C%20p_f_given_e)%3A%0A%20%20%20%20%20%20%20%20return%20p_e%20*%20p_f_given_e%0A%0A%20%20%20%20%23%20Example%201%3A%20Drawing%20two%20hearts%20without%20replacement%0A%20%20%20%20p_first_heart%20%3D%2013%2F52%20%20%20%20%20%20%20%20%23%20P(first%20heart)%0A%20%20%20%20p_second_heart%20%3D%2012%2F51%20%20%20%20%20%20%20%23%20P(second%20heart%20%7C%20first%20heart)%0A%20%20%20%20p_both_hearts%20%3D%20calc_dependent_prob(p_first_heart%2C%20p_second_heart)%0A%20%20%20%20print(f%22Example%201%3A%20P(two%20hearts)%20%3D%20%7Bp_first_heart%3A.3f%7D%20%C3%97%20%7Bp_second_heart%3A.3f%7D%20%3D%20%7Bp_both_hearts%3A.3f%7D%22)%0A%20%20%20%20return%20calc_dependent_prob%2C%20p_both_hearts%2C%20p_first_heart%2C%20p_second_heart%0A%0A%0A%40app.cell%0Adef%20_(calc_dependent_prob)%3A%0A%20%20%20%20%23%20Example%202%3A%20Drawing%20two%20aces%20without%20replacement%0A%20%20%20%20p_first_ace%20%3D%204%2F52%20%20%20%20%20%20%20%20%20%20%23%20P(first%20ace)%0A%20%20%20%20p_second_ace%20%3D%203%2F51%20%20%20%20%20%20%20%20%20%23%20P(second%20ace%20%7C%20first%20ace)%0A%20%20%20%20p_both_aces%20%3D%20calc_dependent_prob(p_first_ace%2C%20p_second_ace)%0A%20%20%20%20print(f%22Example%202%3A%20P(two%20aces)%20%3D%20%7Bp_first_ace%3A.3f%7D%20%C3%97%20%7Bp_second_ace%3A.3f%7D%20%3D%20%7Bp_both_aces%3A.3f%7D%22)%0A%20%20%20%20return%20p_both_aces%2C%20p_first_ace%2C%20p_second_ace%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%20%20%20%20%23%23%20Multiple%20Events%0A%0A%20%20%20%20%20%20%20%20For%20multiple%20independent%20events%3A%0A%0A%20%20%20%20%20%20%20%20%24P(E_1%20%5Ctext%7B%20and%20%7D%20E_2%20%5Ctext%7B%20and%20%7D%20%5Ccdots%20%5Ctext%7B%20and%20%7D%20E_n)%20%3D%20%5Cprod_%7Bi%3D1%7D%5En%20P(E_i)%24%0A%0A%20%20%20%20%20%20%20%20For%20dependent%20events%3A%0A%0A%20%20%20%20%20%20%20%20%24P(E_1%20%5Ctext%7B%20and%20%7D%20E_2%20%5Ctext%7B%20and%20%7D%20%5Ccdots%20%5Ctext%7B%20and%20%7D%20E_n)%20%3D%20P(E_1)%20%5Ccdot%20P(E_2%7CE_1)%20%5Ccdot%20P(E_3%7CE_1%2CE_2)%20%5Ccdots%20P(E_n%7CE_1%2C%5Cldots%2CE_%7Bn-1%7D)%24%0A%0A%20%20%20%20%20%20%20%20Let's%20visualize%20these%20probabilities%3A%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%23%23%23%20Interactive%20example%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(event_type)%3A%0A%20%20%20%20event_type%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20event_type%20%3D%20mo.ui.dropdown(%0A%20%20%20%20%20%20%20%20options%3D%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Independent%20AND%20(Die%20and%20Coin)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Dependent%20AND%20(Sequential%20Cards)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Multiple%20AND%20(System%20Components)%22%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20value%3D%22Independent%20AND%20(Die%20and%20Coin)%22%2C%0A%20%20%20%20%20%20%20%20label%3D%22Select%20AND%20Probability%20Scenario%22%0A%20%20%20%20)%0A%20%20%20%20return%20(event_type%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(event_type%2C%20mo%2C%20plt%2C%20venn2)%3A%0A%20%20%20%20%23%20Define%20the%20events%20and%20their%20probabilities%0A%20%20%20%20events_data%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%22Independent%20AND%20(Die%20and%20Coin)%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22sets%22%3A%20(0.33%2C%200.17%2C%200.08)%2C%20%20%23%20(die%2C%20coin%2C%20intersection)%0A%20%20%20%20%20%20%20%20%20%20%20%20%22labels%22%3A%20(%22Die%5CnP(6)%3D1%2F6%22%2C%20%22Coin%5CnP(H)%3D1%2F2%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22title%22%3A%20%22Independent%20Events%3A%20Rolling%20a%206%20AND%20Getting%20Heads%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22explanation%22%3A%20r%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%23%23%20Independent%20Events%3A%20Die%20Roll%20and%20Coin%20Flip%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%24P(%5Ctext%7BRolling%206%7D)%20%3D%20%5Cfrac%7B1%7D%7B6%7D%20%5Capprox%200.17%24%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%24P(%5Ctext%7BGetting%20Heads%7D)%20%3D%20%5Cfrac%7B1%7D%7B2%7D%20%3D%200.5%24%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%24P(%5Ctext%7B6%20and%20Heads%7D)%20%3D%20%5Cfrac%7B1%7D%7B6%7D%20%5Ctimes%20%5Cfrac%7B1%7D%7B2%7D%20%3D%20%5Cfrac%7B1%7D%7B12%7D%20%5Capprox%200.08%24%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20These%20events%20are%20independent%20because%20the%20outcome%20of%20the%20die%20roll%20%0A%20%20%20%20%20%20%20%20%20%20%20%20doesn't%20affect%20the%20coin%20flip%2C%20and%20vice%20versa.%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%22%22%2C%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22Dependent%20AND%20(Sequential%20Cards)%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22sets%22%3A%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200.25%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200.24%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200.06%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%20%20%23%20(first%20heart%2C%20second%20heart%2C%20intersection)%0A%20%20%20%20%20%20%20%20%20%20%20%20%22labels%22%3A%20(%22First%5CnP(H%E2%82%81)%3D13%2F52%22%2C%20%22Second%5CnP(H%E2%82%82%7CH%E2%82%81)%3D12%2F51%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22title%22%3A%20%22Dependent%20Events%3A%20Drawing%20Two%20Hearts%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22explanation%22%3A%20r%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%23%23%20Dependent%20Events%3A%20Drawing%20Hearts%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%24P(%5Ctext%7BFirst%20Heart%7D)%20%3D%20%5Cfrac%7B13%7D%7B52%7D%20%3D%200.25%24%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%24P(%5Ctext%7BSecond%20Heart%7D%7C%5Ctext%7BFirst%20Heart%7D)%20%3D%20%5Cfrac%7B12%7D%7B51%7D%20%5Capprox%200.24%24%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%24P(%5Ctext%7BBoth%20Hearts%7D)%20%3D%20%5Cfrac%7B13%7D%7B52%7D%20%5Ctimes%20%5Cfrac%7B12%7D%7B51%7D%20%5Capprox%200.06%24%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20These%20events%20are%20dependent%20because%20drawing%20the%20first%20heart%20%0A%20%20%20%20%20%20%20%20%20%20%20%20changes%20the%20probability%20of%20drawing%20the%20second%20heart.%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%22%22%2C%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22Multiple%20AND%20(System%20Components)%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22sets%22%3A%20(0.05%2C%200.03%2C%200.0015)%2C%20%20%23%20(CPU%20fail%2C%20disk%20fail%2C%20intersection)%0A%20%20%20%20%20%20%20%20%20%20%20%20%22labels%22%3A%20(%22CPU%5CnP(C)%3D0.05%22%2C%20%22Disk%5CnP(D)%3D0.03%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22title%22%3A%20%22Independent%20System%20Failures%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22explanation%22%3A%20r%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%23%23%20System%20Component%20Failures%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%24P(%5Ctext%7BCPU%20Failure%7D)%20%3D%200.05%24%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%24P(%5Ctext%7BDisk%20Failure%7D)%20%3D%200.03%24%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%24P(%5Ctext%7BBoth%20Fail%7D)%20%3D%200.05%20%5Ctimes%200.03%20%3D%200.0015%24%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20Component%20failures%20are%20typically%20independent%20in%20**well-designed%20systems**%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20meaning%20one%20component's%20failure%20doesn't%20affect%20the%20other's%20probability%20of%20failing.%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%22%22%2C%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%7D%0A%0A%20%20%20%20%23%20Get%20data%20for%20selected%20event%20type%0A%20%20%20%20data%20%3D%20events_data%5Bevent_type.value%5D%0A%0A%20%20%20%20%23%20Create%20visualization%0A%20%20%20%20plt.figure(figsize%3D(10%2C%205))%0A%20%20%20%20v%20%3D%20venn2(subsets%3Ddata%5B%22sets%22%5D%2C%20set_labels%3Ddata%5B%22labels%22%5D)%0A%20%20%20%20plt.title(data%5B%22title%22%5D)%0A%0A%20%20%20%20%23%20Display%20explanation%20alongside%20visualization%0A%20%20%20%20mo.hstack(%5Bplt.gcf()%2C%20mo.md(data%5B%22explanation%22%5D)%5D)%0A%20%20%20%20return%20data%2C%20events_data%2C%20v%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%20%20%20%20%23%23%20%F0%9F%A4%94%20Test%20Your%20Understanding%0A%0A%20%20%20%20%20%20%20%20Which%20of%20these%20statements%20about%20AND%20probability%20are%20true%3F%0A%0A%20%20%20%20%20%20%20%20%3Cdetails%3E%0A%20%20%20%20%20%20%20%20%3Csummary%3E1.%20The%20probability%20of%20getting%20two%20sixes%20in%20a%20row%20with%20a%20fair%20die%20is%201%2F36%3C%2Fsummary%3E%0A%0A%20%20%20%20%20%20%20%20%E2%9C%85%20True!%20Since%20die%20rolls%20are%20independent%20events%3A%0A%20%20%20%20%20%20%20%20P(two%20sixes)%20%3D%20P(first%20six)%20%C3%97%20P(second%20six)%20%3D%201%2F6%20%C3%97%201%2F6%20%3D%201%2F36%0A%20%20%20%20%20%20%20%20%3C%2Fdetails%3E%0A%0A%20%20%20%20%20%20%20%20%3Cdetails%3E%0A%20%20%20%20%20%20%20%20%3Csummary%3E2.%20When%20drawing%20cards%20without%20replacement%2C%20P(two%20kings)%20%3D%204%2F52%20%C3%97%204%2F52%3C%2Fsummary%3E%0A%0A%20%20%20%20%20%20%20%20%E2%9D%8C%20False!%20This%20is%20a%20dependent%20event.%20The%20correct%20calculation%20is%3A%0A%20%20%20%20%20%20%20%20P(two%20kings)%20%3D%20P(first%20king)%20%C3%97%20P(second%20king%20%7C%20first%20king)%20%3D%204%2F52%20%C3%97%203%2F51%0A%20%20%20%20%20%20%20%20%3C%2Fdetails%3E%0A%0A%20%20%20%20%20%20%20%20%3Cdetails%3E%0A%20%20%20%20%20%20%20%20%3Csummary%3E3.%20If%20P(A)%20%3D%200.3%20and%20P(B)%20%3D%200.4%2C%20then%20P(A%20and%20B)%20must%20be%200.12%3C%2Fsummary%3E%0A%0A%20%20%20%20%20%20%20%20%E2%9D%8C%20False!%20P(A%20and%20B)%20%3D%200.12%20only%20if%20A%20and%20B%20are%20independent%20events.%0A%20%20%20%20%20%20%20%20If%20they're%20dependent%2C%20we%20need%20P(B%7CA)%20to%20calculate%20P(A%20and%20B).%0A%20%20%20%20%20%20%20%20%3C%2Fdetails%3E%0A%0A%20%20%20%20%20%20%20%20%3Cdetails%3E%0A%20%20%20%20%20%20%20%20%3Csummary%3E4.%20The%20probability%20of%20rolling%20a%20six%20AND%20getting%20tails%20is%20(1%2F6%20%C3%97%201%2F2)%3C%2Fsummary%3E%0A%0A%20%20%20%20%20%20%20%20%E2%9C%85%20True!%20These%20are%20independent%20events%2C%20so%20we%20multiply%20their%20individual%20probabilities%3A%0A%20%20%20%20%20%20%20%20P(six%20and%20tails)%20%3D%20P(six)%20%C3%97%20P(tails)%20%3D%201%2F6%20%C3%97%201%2F2%20%3D%201%2F12%0A%20%20%20%20%20%20%20%20%3C%2Fdetails%3E%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20%23%23%20Summary%0A%0A%20%20%20%20%20%20%20%20You've%20learned%3A%0A%0A%20%20%20%20%20%20%20%20-%20How%20to%20identify%20independent%20vs%20dependent%20events%0A%20%20%20%20%20%20%20%20-%20The%20multiplication%20rule%20for%20independent%20events%0A%20%20%20%20%20%20%20%20-%20The%20chain%20rule%20for%20dependent%20events%0A%20%20%20%20%20%20%20%20-%20How%20to%20extend%20these%20concepts%20to%20multiple%20events%0A%0A%20%20%20%20%20%20%20%20In%20the%20next%20lesson%2C%20we'll%20explore%20**law%20of%20total%20probability**%20in%20more%20detail%2C%20building%20on%20our%20understanding%20of%20various%20topics.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A</marimo-code></head>
<body>
<div id="root"></div>
</body>
</html>