lewisjjj800
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • Create new note
      • Create a note from template
        • Sharing URL Link copied
        • /edit
        • View mode
          • Edit mode
          • View mode
          • Book mode
          • Slide mode
          Edit mode View mode Book mode Slide mode
        • Customize slides
        • Note Permission
        • Read
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Write
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invite by email
        Invitee

        This note has no invitees

      • Publish Note

        Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

        Your note will be visible on your profile and discoverable by anyone.
        Your note is now live.
        This note is visible on your profile and discoverable online.
        Everyone on the web can find and read all notes of this public team.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        See published notes
        Unpublish note
        Please check the box to agree to the Community Guidelines.
        View profile
      • Commenting
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Suggest edit
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
      • Emoji Reply
      • Enable
      • Versions and GitHub Sync
      • Note settings
      • Note Insights New
      • Engagement control
      • Make a copy
      • Transfer ownership
      • Delete this note
      • Save as template
      • Insert from template
      • Import from
        • Dropbox
        • Google Drive
        • Gist
        • Clipboard
      • Export to
        • Dropbox
        • Google Drive
        • Gist
      • Download
        • Markdown
        • HTML
        • Raw HTML
    Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Engagement control Make a copy Transfer ownership Delete this note
    Import from
    Dropbox Google Drive Gist Clipboard
    Export to
    Dropbox Google Drive Gist
    Download
    Markdown HTML Raw HTML
    Back
    Sharing URL Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Customize slides
    Note Permission
    Read
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Write
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- title: 【數學理論】 03. 你該更換你的選擇嗎?(上) — 蒙提霍爾悖論 (Monty Hall Paradox) tags: - 【數學理論】 - 悖論 url: https://hackmd.io/r3NazCD3SmSMlH-oNDjt1A lastSync: 2025-05-25T08:45:23.560Z hackmd: url: https://hackmd.io/r3NazCD3SmSMlH-oNDjt1A title: 【數學理論】 03. 你該更換你的選擇嗎?(上) — 蒙提霍爾悖論 (Monty Hall Paradox) lastSync: 2025-05-25T05:17:09.493Z --- 你該更換你的選擇嗎?(上) === <font size=4><font color=gray>蒙提霍爾悖論 (Monty Hall Paradox)</font><br></font><br> --- <!-- 20251012 --> 開頭先來說一個故事。 <br> 國中的時候曾看過一部電影:**《決勝21點》**,內容講述一個立志要成為醫生的麻省理工天才學生**因緣際會**下,被教授發現數學才能與冷靜分析的能力,因而被邀請到21點的算牌團隊,開始一段高潮迭起的故事。還沒看過的人可以上Netflix找來看,劇情是真的很不錯。 <br> <img src="https://raw.githubusercontent.com/lewisjjj800soic/HackMD-images-backup/main/Mathematic-Theorems/03/01.jpg" alt="圖片描述" style="display: block; margin: 0 auto;" width="300"> > <font size=1><font color=gray>photo credit by: https://www.agentm.tw/movie_page?m_id=e663603a6a3cdd398eed6e6dbc80a3862422a9adc1b1e59138e804b934b20082</font></font> <br> 那這個「**因緣際會**」是怎麼來的呢?某一天主角課堂上的教授,也就是算牌團隊的領導出了一個問題: >[!Note] **三門問題** **有一個電視節目,提供有三扇門給挑戰者選擇,一扇門後面是<font color=red>跑車</font>,其餘兩扇門後面是<font color=blue>山羊</font>,門長得都一樣,如果選中的門後是<font color=red>跑車</font>就能直接帶走。當然一開始挑戰者無法得知哪扇門後面是<font color=red>跑車</font>,只有主持人知道。當挑戰者選定其中一扇門之後,主持人會直接刪除一扇後面是<font color=blue>山羊</font>的門,接著會給挑戰者是否要換門的機會,請問該換還是不換?** <br> 這就是今天的主題:「**三門問題**」 <br> 主角很快就秒答結果:「應該要換」,並且給出了解釋,國中時候的我實在是看得一愣一楞的,高中代表學校參加數學學科競賽的時候也曾跟朋友討論過這個問題,一直到我深入研究並寫出這篇專欄之前我都不敢說我自己完全理解,那既然要寫個研究專欄,那就來一起把這個困惑許多人的「**三門問題**」一次搞懂吧! <br> 「三門問題」又被稱作是「**蒙提霍爾悖論**」,因為這個問題的解答是「應該要換」,一般人會覺得既然主持人都知道門後有什麼,怕主持人會欺騙自己,所以堅持己見不更換選擇,然而事實上以三門問題來說,更換選擇會讓贏得汽車的機率會增加33.33%,由於這個解答違反直覺與常理,所以又被歸類在「悖論」當中。 <br> 提到「悖論」,說個題外話。 <br> 在數學上有很多經典的悖論問題,例如「**生日悖論**」、「**伯特蘭箱子悖論**」以及今天要討論的「**蒙提霍爾悖論**」等等…接下來會開一個以「**數學悖論**」為主的系列。 <br> 回到主題,蒙提霍爾悖論的解答很簡單,就是換就對了,但是要解釋起來卻很複雜,可以很數學、也可以很直觀,今天我就從數學方面思考,最後再以直觀的解釋概括這一切。 <br> > [!TIP] **提醒** > 一樣按照慣例,接下來的篇幅會充滿數學式,如果你極度討厭數學、看到數學課本只會想撕爛、恨不得數學從教育裡拔掉的人,請直接跳到[**這裡開始往下**](https://hackmd.io/@lewisjjj800/By8kdQlzxg?view#%E7%AA%AE%E8%88%89%E8%AD%89%E6%98%8E%E6%B3%95)看結論吧XD。 <br> 要以數學方式來探討這個經典的問題,就要用**機率**來探討。而提到機率就不得不提到你我高中都學過的 **「貝式定理 (Bayes' theorem)」**。 <br> ## **貝式定理 (Bayes' theorem)** 貝式定理探討的是:「**描述在已知一些條件下,某事件的發生機率。**」,乍聽之下跟條件機率有關,而確實貝式定理是條件機率的一種衍伸,讓我來幫高中學過貝式定理的你回憶一下它的長相: <br> > [!Note] **貝式定理 (Bayes' theorem)** > $P(H \vert E)=\dfrac{P(H)P(E \vert H)}{P(E)}$ <br> 其中 $P(H \vert E)$ 代表「後驗機率 (Posterior Probability)」 $P(H)$ 代表「先驗機率 (Prior Probability)」 $P(E \vert H)$ 代表「概似性 (Likelihood)」 <br> 為了瞭解這幾個名詞的涵義,讓我來舉個例子。 <br> 生在雨都、長在雨都又在雨都唸超過10年書的我,就以**降雨機率**來舉例。 <br> 首先我們先來看看根據**中央氣象局統計基隆市2019年到2023年這五年的降雨天數數據**。 <br> | | 2019年 | 2020年 | 2021年 | 2022年 | 2023年 | |-|--|---|----|-----|------| | 沒下雨 | 137天 | 161天 | 134天 | 109天 | 151天 | | 微微雨 | 14天 | 15天 | 65天 | 46天 | 37天 | | 有下雨 | 214天 | 190天 | 166天 | 210天 | 177天 | >微微雨代表降雨量小於0.5mm <br> 身為土生土長基隆人,微微雨這種超小雨量根本不算下雨,因此將沒下雨跟微微雨的數據合併在一起,根據這個數據,可以計算出基隆降雨機率應該是: <br> $\dfrac{總天數}{下雨天數}=\dfrac{214+190+166+210+177}{365+366+365+365+365}\approx52\%$ <br> 但你我肯定都遇過一種情況,就是出門前沒下雨,但天空烏雲密布,一出門沒多久就下雨的情況,因此我們不能單看降雨機率判斷要不要帶傘,必須將「**出門前是陰天,但出門後卻降雨**」的機率納入考量。 <br> 假設我們經過統計,在過去100天雨天當中為陰天的天數共有80天;而在過去100天非雨天當中為陰天的天數僅有30天,因此我們可以根據幾種事件列出以下機率: <br> $P(H \vert E)$:基隆地區的降雨機率 $P(¬H)$:基隆地區沒下雨的機率 <font color=gray>~~(體感為0)~~</font> $P(E \vert H)$:在雨天的情況下,為陰天的機率 $P(E \vert ¬H)$:在非雨天的情況下,為陰天的機率 $P(E)$:陰天的機率總和 <br> 這個時候我們就能計算出以下各種機率: $P(H)=52\%$ $P(¬H)=1-P(H)=48\%$ $P(E \vert H)=\dfrac{過去100天雨天當中為陰天的天數}{過去100天雨天}=\dfrac{80}{100}=80\%$ $P(E \vert ¬H)=\dfrac{過去100天非雨天當中為陰天的天數}{過去100天非雨天}=\dfrac{30}{100}=30\%$ $P(E)=有下雨而且是陰天的機率+沒下雨而且是陰天的機率$ &ensp;&nbsp;&ensp;&ensp;&emsp;$=P(H)\times P(E \vert H)+P(¬H)\times P(E \vert ¬H)$ &ensp;&nbsp;&ensp;&ensp;&emsp;$=52\% \times 80\% + 48\% \times 30\% =56\%$ <br> 接下來我們就可以應用**貝式定理** $P(H \vert E)=\dfrac{P(H)P(E \vert H)}{P(E)}=\dfrac{P(H)P(E \vert H)}{P(H)\times P(E \vert H)+P(¬H)\times P(E \vert ¬H)}$ <br> 然後把上面的數據代入貝式定理公式: <br> $P(H \vert E)=\dfrac{0.52\times 0.8}{0.52\times 0.8+0.48\times 0.3} \approx74\%$ <br> 代表將陰天這個事件考慮進來的話,降雨機率就會從原本的$52\%$提升到$74\%$ <br> 由此可知,當新的事件被納入考量後,事件發生前的機率就會有所更新,這就是貝式定理的精隨 <br> <font size=5>**事後機率** $=$ **倍數關係** $\times$ **事前機率**</font><br> <br> 此時我們知道了,當觀察到外面是陰天,降雨機率會提升到 $74\%$ <br> 但我仍然不信邪呢?管他的反正也才 $74\%$ <br> 正當我毅然決然出門時,我媽開口了 <br> <font size=5>**「要記得帶傘哦,今天會下雨」**</font><br> <br> 我想每個人的媽媽都有特異功能,我媽當然不例外,我媽除了會**燒了一桌好菜**、**找到我找了三個小時翻遍家裡都找不到的東西**以外,還有一項特異功能就是能夠**精準預測天氣**。 <br> 新的事件又來了: <font size=5>**「當外面觀察到陰天,我媽又說『今天會下雨』,那這時降雨機率會是多少呢?」**</font><br> <br> 那這時我想已經清楚了解貝式定理的你應該知道這題怎麼做了。我回憶過去<font color=gray>~~(痛苦的相思忘不了)~~</font>,在過去100天雨天當中我媽說中會下雨的天數高達驚人的**95天**,因此我們可以根據幾種事件列出以下機率: $P(H \vert E)$:觀察到天氣是陰天時的降雨機率 $P(¬H)$:觀察到天氣是陰天卻沒降雨的機率 <font color=gray>~~(基本上不可能)~~</font> $P(E \vert H)$:我媽說中會下雨的機率 $P(E \vert ¬H)$:我媽說會下雨但卻沒下雨的機率 $P(E)$:我媽說會下雨的機率總和 >[!Note] 註 >$P(E \vert H)$ 可以理解為我媽說會下雨的準確率 <br> 這個時候我們一樣能計算出以下各種機率: <br> $P(H)=74\%$ $P(¬H)=1-P(H)=26\%$ $P(E \vert H)=\dfrac{過去100天雨天當中我媽說中會下雨的天數}{過去100天雨天}=\dfrac{95}{100}=95\%$ $P(E \vert ¬H)=\dfrac{過去100天雨天當中我媽說會下雨但卻沒下雨的機率}{過去100天雨天}=\dfrac{5}{100}=5\%$ $P(E)=P(H)\times P(E \vert H)+P(¬H)\times P(E \vert ¬H)\\=74\% \times 95\% + 26\% \times 5\% \approx83.3\%$ <br> 接下來我們就可以應用**貝式定理**,把上面的數據代入貝式定理公式: <br> $P(H \vert E)=\dfrac{0.74\times 0.95}{0.74\times 0.95+0.26\times 0.05} \approx84\%$ <br> 代表除了將陰天這個事件考慮進來以外,再加上我媽神準的預測,降雨機率就會從原本的$74\%$又一次提升到$84\%$,這時出門沒下雨也難了。 <br> 現在你大概也清楚貝式定理是如何計算的,最後再舉一個貼近你我生活的例子來說明貝式定理為什麼在討論機率時這麼重要。 <br> # <font size=5>**新冠病毒PCR檢測**</font><br> 假設新冠病毒PCR檢測結果的靈敏度和特異度均為$99\%$,即確診者每次PCR檢測呈**陽性**的機率為$99\%$。而非確診者每次PCR檢測呈**陰性**的機率也是$99\%$。從檢測結果的機率來看,PCR檢測結果是比較準確的,但是事實真的是如此嗎? 現在我們用貝式定理分析一下:假設將某醫院對所有院內人員進行PCR檢測,已知現在有$0.5\%$的人確診。請問每位檢測結果呈陽性的院內人員真實確診的機率有多高? $P(H \vert E)$:院內人員確診機率 $P(¬H)$:院內人員沒確診的機率 $P(E \vert H)$:在院內人員確診的情況下,PCR檢測呈陽性的機率 $P(E \vert ¬H)$:在院內人員沒確診的情況下,PCR檢測呈陽性的機率 $P(E)$:PCR檢測呈陽性的機率總和 這個時候我們就能計算出以下各種機率: $P(H)=0.5\%$ $P(¬H)=1-P(H)=99.5\%$ $P(E \vert H)=99\%$ $P(E \vert ¬H)=1\%$ $P(E)=確診且陽性的機率+沒確診且陽性的機率$ &ensp;&nbsp;&ensp;&ensp;&emsp;$=P(H)\times P(E \vert H)+P(¬H)\times P(E \vert ¬H)$ &ensp;&nbsp;&ensp;&ensp;&emsp;$=0.5\% \times 99\% + 99.5\% \times 1\% =1.49\%$ 接下來一樣應用**貝式定理**,把上面的數據代入貝式定理公式: <br> $P(H \vert E)=\dfrac{0.005\times 0.99}{0.005\times 0.99+0.995\times 0.01} \approx33\%$ <br> 代表雖然PCR檢測的準確率達到$99\%$,但實際情況是,在檢驗出陽性的情況下,真正確診的人竟然只有$33\%$。 <br> 這是因為假設總共有1000人接受PCR檢測,其中只有5人確診,其餘995人沒確診,但因為沒確診的人很多,所以就算只有 $1\%$ 會出錯,沒確診被檢驗出陽性的人數大概等於$1\% \times 995人 \approx 10人左右$,但真正確診被檢測出陽性的人只有 $99\% \times 5人 \approx 5人$,總共被檢驗出陽性的人共有15人,但只有5人確診,準確率僅有 $33\%$ <br> 透過這個例子我們可以瞭解到機率可能會出現反直覺的情況,而透過貝式定理就可以揭開這反直覺的神秘面紗。 <br> 希望你還記得這次專欄的主題「**蒙提霍爾悖論**」,在[**下篇**](https://hackmd.io/@lewisjjj800/By8kdQlzxg)我就會著重在如何破解這名為悖論的數學問題。

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully