楼主: ReneeBK
3894 19

【Programming using PyMC3】Statistical Rethinking with Python and PyMC3 [推广有奖]

  • 1关注
  • 62粉丝

VIP

已卖:4900份资源

学术权威

14%

还不是VIP/贵宾

-

TA的文库  其他...

R资源总汇

Panel Data Analysis

Experimental Design

威望
1
论坛币
49655 个
通用积分
55.9937
学术水平
370 点
热心指数
273 点
信用等级
335 点
经验
57805 点
帖子
4005
精华
21
在线时间
582 小时
注册时间
2005-5-8
最后登录
2023-11-26

楼主
ReneeBK 发表于 2016-12-11 10:32:33 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
Statistical Rethinking with Python and PyMC3

Statistical Rethinking is an incredible good introductory book to Bayesian Statistics, its follows a Jaynesian and practical approach with very good examples and clear explanations.

In this repository I am (slowly) porting the examples in the book to PyMC3. I am trying to keep the examples as close as possible to those in the book, while at the same time I am trying to express them in the most Pythonic and PyMC3onic way I can.

All contributions are wellcome!

本帖隐藏的内容

Statistical-Rethinking-with-Python-and-PyMC3-master.zip (1.72 MB, 需要: 5 个论坛币)




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Statistical Programming statistica Rethinking statistic practical examples possible trying close

本帖被以下文库推荐

沙发
ReneeBK(未真实交易用户) 发表于 2016-12-11 10:34:21
  1. %matplotlib inline
  2. import pymc3 as pm
  3. import numpy as np
  4. import scipy.stats as stats
  5. import matplotlib.pyplot as plt
  6. import seaborn as sns; sns.set_palette('colorblind'); sns.set_color_codes()
复制代码

藤椅
ReneeBK(未真实交易用户) 发表于 2016-12-11 10:34:39
  1. ways = np.array([0, 3, 8, 9, 0])
  2. ways/ways.sum()
复制代码

板凳
ReneeBK(未真实交易用户) 发表于 2016-12-11 10:35:03
  1. stats.binom.pmf(6, n=9, p=0.5)
复制代码

报纸
bingyang1008(真实交易用户) 发表于 2016-12-11 10:35:28
感谢分享

地板
ReneeBK(未真实交易用户) 发表于 2016-12-11 10:35:33
  1. ef posterior_grid_approx(grid_points=5, success=6, tosses=9):
  2.     """
  3.     """
  4.     # define grid
  5.     p_grid = np.linspace(0, 1, grid_points)

  6.     # define prior
  7.     prior = np.repeat(5, grid_points)  # uniform
  8.     #prior = (p_grid >= 0.5).astype(int)  # truncated
  9.     #prior = np.exp(- 5 * abs(p_grid - 0.5))  # double exp

  10.     # compute likelihood at each point in the grid
  11.     likelihood = stats.binom.pmf(success, tosses, p_grid)

  12.     # compute product of likelihood and prior
  13.     unstd_posterior = likelihood * prior

  14.     # standardize the posterior, so it sums to 1
  15.     posterior = unstd_posterior / unstd_posterior.sum()
  16.     return p_grid, posterior
复制代码

7
ReneeBK(未真实交易用户) 发表于 2016-12-11 10:37:06
  1. data = np.repeat((0, 1), (3, 6))
  2. with pm.Model() as normal_aproximation:
  3.     p = pm.Uniform('p', 0, 1, transform=None)
  4.     w = pm.Binomial('w', n=len(data), p=p, observed=data.sum())
  5.     mean_q = pm.find_MAP()
  6.     std_q = ((1/pm.find_hessian(mean_q))**0.5)[0]
  7. mean_q['p'], std_q
复制代码

8
ReneeBK(未真实交易用户) 发表于 2016-12-11 10:37:47
  1. # analytical calculation
  2. w, n = 6, 9
  3. x = np.linspace(0, 1, 100)
  4. plt.plot(x, stats.beta.pdf(x , w+1, n-w+1), label='True posterior')
  5. # quadratic approximation
  6. plt.plot(x, stats.norm.pdf(x, mean_q['p'], std_q), label='Quadratic approximation')
  7. plt.legend(loc=0);
复制代码

9
ReneeBK(未真实交易用户) 发表于 2016-12-11 10:38:18
  1. import sys, IPython, scipy, matplotlib, platform
  2. print("This notebook was createad on a computer %s running %s and using:\nPython %s\nIPython %s\nPyMC3 %s\nNumPy %s\nSciPy %s\nMatplotlib %s\nSeaborn %s\n" % (platform.machine(), ' '.join(platform.linux_distribution()[:2]), sys.version[:5], IPython.__version__, pm.__version__, np.__version__, scipy.__version__, matplotlib.__version__, sns.__version__))
复制代码

10
mengyong(真实交易用户) 发表于 2016-12-11 10:46:55
Applications of Differential Geometry to

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-17 13:50