对换钱悖论的贝叶斯分析

Posted on Tue 04 April 2017 in ProbStat

问题的提出

现在邀请你和一位路人甲来做一个游戏:我拿出两个信封分别递给你们,并告诉你 们一个装着的钱是另一个的两倍(但不知道哪个多哪个少)。你们有一次互相交换 的机会,想交换吗?然后打开信封,看一下自己拿到的钱数(但不要让对方知道),现在还想交换吗?

——引自0x01.me

这段话似乎可以引出一个悖论:

换钱后,有一半的概率钱变成原来的两倍,一半概率钱减少到原来的一半,因此期望收益是大于零的。然而另一方面,两份钱显然是对称的,因此不可能总是由换钱带来收益。

下面我们用贝叶斯来分析这个悖论。

贝叶斯分析

假设发钱时,钱少的那个钱数取$y$的先验分布为$\rho(y)$。设某人抽到了钱数是$x$,则此时$y$的取值可以是$x$或者$x/2$。

参数$y$下$x$的分布是 $$p …


Continue reading

Blogging with Jupyter and Pelican

Posted on Thu 30 March 2017 in Computer

This articles tells how to build this blog site.

Installation and Setup

  • Jupyter, and an article telling what is jupyter notebook
  • Pelican, pythonic blog system supports markdown, rst, asciidoc, ipynb etc.
  • ipynb2pelican, a plugin enables ipynb support by metacell
  • ghp-import is needed for github page import. It can be installed …

Continue reading

ipynb2pelican Plugin released!

Posted on Mon 27 March 2017 in Computer

Yet another Pelican Plugin for blogging with Jupyter Notebooks using MetaCell to store metadata.

Thanks to super cow power of python, we can finally publish ipynb easily! Below is the README.md from the project at this time.

The ipynb2pelican plugin provides markup for Jupyter/IPython notebooks in pelican, so …


Continue reading

Next Permutation

Posted on Fri 24 March 2017 in Puzzles

Aim: Find a larger permutation

We must move a larger number forward. So we should go from the tail to find any new number is smaller than a number behind it. If no next permutation, reverse list.

In [ ]:
def next_permutation(l):
    '''Give out the next permutation of list l
    >>> next_permutation …

Continue reading

Notes for Chapter 4. Gaussian Models

Posted on Mon 20 March 2017 in MLAPP


Continue reading

Solutions for Chapter 4. Gaussian Models

Posted on Mon 20 March 2017 in MLAPP


Continue reading

Solutions for Chapter 3 Generative models for discrete data

Posted on Thu 09 March 2017 in MLAPP


Continue reading

Notes on Chapter 2 Probability

Posted on Wed 08 March 2017 in MLAPP


Continue reading

Solutions for Chapter 2 Probability

Posted on Wed 08 March 2017 in MLAPP


Continue reading

Solutions for MLAPP

Posted on Mon 06 March 2017 in MLAPP

This project includes my solutions and notes to the book Machine Learning: a Probabilistic Perspective by Kevin Patrick Murphy when I was learning this book.

The solutions are written in the Jupyter Notebook format .ipynb, which supports python/markdown cells with pretty output. Solutions are written in markdown cells with …


Continue reading