Skip to content

Commit

Permalink
add note
Browse files Browse the repository at this point in the history
add understanding bayes note
  • Loading branch information
math4mad committed Oct 20, 2023
1 parent 0a792d1 commit 65f7652
Show file tree
Hide file tree
Showing 27 changed files with 993 additions and 55 deletions.
6 changes: 6 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@
<a href="./statistics/12-likelihood-coin-toss.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">12-likelihood of coin toss</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./statistics/13-understand-bayes.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">13-understanding-bayes</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
Expand Down
6 changes: 6 additions & 0 deletions docs/machinelearning/1-classfication-comparison.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@
<a href="../statistics/12-likelihood-coin-toss.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">12-likelihood of coin toss</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../statistics/13-understand-bayes.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">13-understanding-bayes</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
Expand Down
6 changes: 6 additions & 0 deletions docs/materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@
<a href="./statistics/12-likelihood-coin-toss.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">12-likelihood of coin toss</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./statistics/13-understand-bayes.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">13-understanding-bayes</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
Expand Down
6 changes: 6 additions & 0 deletions docs/math/1-double-integral.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@
<a href="../statistics/12-likelihood-coin-toss.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">12-likelihood of coin toss</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../statistics/13-understand-bayes.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">13-understanding-bayes</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
Expand Down
6 changes: 6 additions & 0 deletions docs/math/2-function.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@
<a href="../statistics/12-likelihood-coin-toss.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">12-likelihood of coin toss</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../statistics/13-understand-bayes.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">13-understanding-bayes</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
Expand Down
6 changes: 6 additions & 0 deletions docs/math/3-oval-spere.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@
<a href="../statistics/12-likelihood-coin-toss.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">12-likelihood of coin toss</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../statistics/13-understand-bayes.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">13-understanding-bayes</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
Expand Down
6 changes: 6 additions & 0 deletions docs/math/4-one-variable-integral.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@
<a href="../statistics/12-likelihood-coin-toss.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">12-likelihood of coin toss</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../statistics/13-understand-bayes.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">13-understanding-bayes</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
Expand Down
6 changes: 6 additions & 0 deletions docs/math/5-himmelblau-function.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@
<a href="../statistics/12-likelihood-coin-toss.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">12-likelihood of coin toss</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../statistics/13-understand-bayes.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">13-understanding-bayes</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
Expand Down
6 changes: 6 additions & 0 deletions docs/schedule.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@
<a href="./statistics/12-likelihood-coin-toss.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">12-likelihood of coin toss</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./statistics/13-understand-bayes.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">13-understanding-bayes</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
Expand Down
128 changes: 78 additions & 50 deletions docs/search.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions docs/statistics/1-normaldist.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@
<a href="../statistics/12-likelihood-coin-toss.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">12-likelihood of coin toss</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../statistics/13-understand-bayes.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">13-understanding-bayes</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
Expand Down
6 changes: 6 additions & 0 deletions docs/statistics/10-dirichlet-dist.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@
<a href="../statistics/12-likelihood-coin-toss.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">12-likelihood of coin toss</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../statistics/13-understand-bayes.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">13-understanding-bayes</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
Expand Down
65 changes: 60 additions & 5 deletions docs/statistics/12-likelihood-coin-toss.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@
<a href="../statistics/12-likelihood-coin-toss.html" class="sidebar-item-text sidebar-link active">
<span class="menu-text">12-likelihood of coin toss</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="../statistics/13-understand-bayes.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">13-understanding-bayes</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
Expand Down Expand Up @@ -302,7 +308,10 @@ <h2 id="toc-title">On this page</h2>
<li><a href="#load-package" id="toc-load-package" class="nav-link active" data-scroll-target="#load-package">1. load package</a></li>
<li><a href="#基本概率模型二项式分布" id="toc-基本概率模型二项式分布" class="nav-link" data-scroll-target="#基本概率模型二项式分布">2. 基本概率模型:二项式分布</a></li>
<li><a href="#硬币试验的不同观测值概率模型定义" id="toc-硬币试验的不同观测值概率模型定义" class="nav-link" data-scroll-target="#硬币试验的不同观测值概率模型定义">3. 硬币试验的不同观测值概率模型定义</a></li>
<li><a href="#次试验不同正面观察结果下的概率密度图" id="toc-次试验不同正面观察结果下的概率密度图" class="nav-link" data-scroll-target="#次试验不同正面观察结果下的概率密度图">4. 10次试验,不同正面观察结果下的概率密度图</a></li>
<li><a href="#次试验不同正面观察结果下的概率密度图" id="toc-次试验不同正面观察结果下的概率密度图" class="nav-link" data-scroll-target="#次试验不同正面观察结果下的概率密度图">4. 10次试验,不同正面观察结果下的概率密度图</a>
<ul class="collapse">
<li><a href="#最大似然率估计的正式方法" id="toc-最大似然率估计的正式方法" class="nav-link" data-scroll-target="#最大似然率估计的正式方法">5. 最大似然率估计的正式方法</a></li>
</ul></li>
</ul>
</nav>
</div>
Expand Down Expand Up @@ -365,7 +374,7 @@ <h2 class="anchored" data-anchor-id="load-package">1. load package</h2>
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">using</span> <span class="bu">Distributions</span>,<span class="bu">GLMakie</span>,<span class="bu">Random</span>,<span class="bu">Pipe</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="bu">Random</span>.<span class="fu">seed!</span>(<span class="fl">123</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-display" data-execution_count="2">
<div class="cell-output cell-output-display" data-execution_count="77">
<pre><code>TaskLocalRNG()</code></pre>
</div>
</div>
Expand All @@ -377,7 +386,7 @@ <h2 class="anchored" data-anchor-id="基本概率模型二项式分布">2. 基
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@doc</span>(Binomial)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-display" data-execution_count="3">
<div class="cell-output cell-output-display" data-execution_count="78">
<pre><code>Binomial(n,p)</code></pre>
<p>A <em>Binomial distribution</em> characterizes the number of successes in a sequence of independent trials. It has two parameters: <code>n</code>, the number of trials, and <code>p</code>, the probability of success in an individual trial, with the distribution:</p>
<p><span class="math display">\[
Expand Down Expand Up @@ -413,7 +422,7 @@ <h2 class="anchored" data-anchor-id="硬币试验的不同观测值概率模型
<span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> (p<span class="op">::</span><span class="dt">Real</span>)<span class="op">-&gt;</span> <span class="pp">@pipe</span> <span class="fu">Binomial</span>(total,p)<span class="op">|&gt;</span><span class="fu">pdf</span>(_,success)</span>
<span id="cb6-8"><a href="#cb6-8" aria-hidden="true" tabindex="-1"></a><span class="kw">end</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-display" data-execution_count="4">
<div class="cell-output cell-output-display" data-execution_count="79">
<pre><code>input_data (generic function with 1 method)</code></pre>
</div>
</div>
Expand Down Expand Up @@ -448,12 +457,58 @@ <h2 class="anchored" data-anchor-id="次试验不同正面观察结果下的概
<span id="cb8-23"><a href="#cb8-23" aria-hidden="true" tabindex="-1"></a><span class="cf">end</span></span>
<span id="cb8-24"><a href="#cb8-24" aria-hidden="true" tabindex="-1"></a>fig</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-display" data-execution_count="5">
<div class="cell-output cell-output-display" data-execution_count="80">
<p><img src="12-likelihood-coin-toss_files/figure-html/cell-5-output-1.png" class="img-fluid"></p>
</div>
</div>
<section id="最大似然率估计的正式方法" class="level3">
<h3 class="anchored" data-anchor-id="最大似然率估计的正式方法">5. 最大似然率估计的正式方法</h3>
<p><code>Distributions.jl</code>提供了<code>fit_mle</code>函数</p>
<div class="cell" data-execution_count="5">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="pp">@doc</span>(fit_mle)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-display" data-execution_count="81">
<pre><code>fit_mle(D, x)</code></pre>
<p>Fit a distribution of type <code>D</code> to a given data set <code>x</code>.</p>
<ul>
<li>For univariate distribution, x can be an array of arbitrary size.</li>
<li>For multivariate distribution, x should be a matrix, where each column is a sample.</li>
</ul>
<pre><code>fit_mle(D, x, w)</code></pre>
<p>Fit a distribution of type <code>D</code> to a weighted data set <code>x</code>, with weights given by <code>w</code>.</p>
<p>Here, <code>w</code> should be an array with length <code>n</code>, where <code>n</code> is the number of samples contained in <code>x</code>.</p>
<pre><code>fit_mle(::Type{&lt;:Beta}, x::AbstractArray{T})</code></pre>
<p>Maximum Likelihood Estimate of <code>Beta</code> Distribution via Newton’s Method</p>
<pre><code>fit_mle(::Type{&lt;:Weibull}, x::AbstractArray{&lt;:Real};
alpha0::Real = 1, maxiter::Int = 1000, tol::Real = 1e-16)</code></pre>
<p>Compute the maximum likelihood estimate of the <a href="@ref"><code>Weibull</code></a> distribution with Newton’s method.</p>
</div>
</div>
<div class="cell" data-execution_count="6">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb14"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> i <span class="kw">in</span> <span class="fl">1</span><span class="op">:</span><span class="fl">10</span></span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="pp">@info</span> <span class="st">"total=10,success=</span><span class="sc">$</span>i<span class="st"> mle"</span><span class="op">=&gt;</span> <span class="fu">fit_mle</span>(Binomial, <span class="fl">10</span>,[i])</span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a><span class="cf">end</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-stderr">
<pre><code>[ Info: "total=10,success=1 mle" =&gt; Binomial{Float64}(n=10, p=0.1)
[ Info: "total=10,success=2 mle" =&gt; Binomial{Float64}(n=10, p=0.2)
[ Info: "total=10,success=3 mle" =&gt; Binomial{Float64}(n=10, p=0.3)
[ Info: "total=10,success=4 mle" =&gt; Binomial{Float64}(n=10, p=0.4)
[ Info: "total=10,success=5 mle" =&gt; Binomial{Float64}(n=10, p=0.5)
[ Info: "total=10,success=6 mle" =&gt; Binomial{Float64}(n=10, p=0.6)
[ Info: "total=10,success=7 mle" =&gt; Binomial{Float64}(n=10, p=0.7)
[ Info: "total=10,success=8 mle" =&gt; Binomial{Float64}(n=10, p=0.8)
[ Info: "total=10,success=9 mle" =&gt; Binomial{Float64}(n=10, p=0.9)
[ Info: "total=10,success=10 mle" =&gt; Binomial{Float64}(n=10, p=1.0)</code></pre>
</div>
</div>


</section>
</section>

</main> <!-- /main -->
Expand Down
Loading

0 comments on commit 65f7652

Please sign in to comment.