没有合适的资源?快使用搜索试试~ 我知道了~
首页Markov Chain Monte Carlo in Python
Markov Chain Monte Carlo in Python
需积分: 18 11 下载量 37 浏览量
更新于2023-03-16
评论
收藏 940KB PDF 举报
Markov Chain Monte Carlo in Python – Towards Data Science
资源详情
资源评论
资源推荐
ApplausefromDaniilKorbut,MichaelBarber,and722others
WilliamKoehrsen
DataScientistatFeatureLabs,DataScienceCommunicator
Feb10 · 12minread
MarkovChainMonteCarloinPython
A Complete Real-World Implementation
The past few months, I encountered one term again and again in the
data science world: Markov Chain Monte Carlo. In my research lab, in
podcasts, in articles, every time I heard the phrase I would nod and
think that sounds pretty cool with only a vague idea of what anyone
was talking about. Several times I tried to learn MCMC and Bayesian
inference, but every time I started reading the books, I soon gave up.
Exasperated, I turned to the best method to learn any new skill: apply it
to a problem.
Using some of my sleep data I had been meaning to explore and a
hands-on application-based book (Bayesian Methods for Hackers,
available free online), I nally learned Markov Chain Monte Carlo
through a real-world project. As usual, it was much easier (and more
enjoyable) to understand the technical concepts when I applied them to
a problem rather than reading them as abstract ideas on a page. This
article walks through the introductory implementation of Markov
Chain Monte Carlo in Python that nally taught me this powerful
modeling and analysis tool.
The full code and data for this project is on GitHub. I encourage anyone
to take a look and use it on their own data. This article focuses on
applications and results, so there are a lot of topics covered at a high
level, but I have tried to provide links for those wanting to learn more!
Introduction
My Garmin Vivosmart watch tracks when I fall asleep and wake up
based on heart rate and motion. It’s not 100% accurate, but real-world
data is never perfect, and we can still extract useful knowledge from
noisy data with the right model!
The objective of this project was to use the sleep data to create a model
that species the posterior probability of sleep as a function of time. As
time is a continuous variable, specifying the entire posterior
distribution is intractable, and we turn to methods to approximate a
distribution, such as Markov Chain Monte Carlo (MCMC).
ChoosingaProbabilityDistribution
Before we can start with MCMC, we need to determine an appropriate
function for modeling the posterior probability distribution of sleep.
One simple way to do this is to visually inspect the data. The
observations for when I fall asleep as a function of time are shown
below.
TypicalSleepData
Every data point is represented as a dot, with the intensity of the dot
showing the number of observations at the specic time. My watch
records only the minute at which I fall asleep, so to expand the data, I
added points to every minute on both sides of the precise time. If my
watch says I fell asleep at 10:05 PM, then every minute before is
represented as a 0 (awake) and every minute after gets a 1 (asleep).
This expanded the roughly 60 nights of observations into 11340 data
points.
We can see that I tend to fall asleep a little after 10:00 PM but we want
to create a model that captures the transition from awake to asleep in
terms of a probability. We could use a simple step function for our
model that changes from awake (0) to asleep (1) at one precise time,
but this would not represent the uncertainty in the data. I do not go to
sleep at the same time every night, and we need a function to that
models the transition as a gradual process to show the variability. The
best choice given the data is a logistic function which is smoothly
transitions between the bounds of 0 and 1. Following is a logistic
equation for the probability of sleep as a function of time
Here, β (beta) and α (alpha) are the parameters of the model that we
must learn during MCMC. A logistic function with varying parameters
is shown below.
SleepingData
剩余13页未读,继续阅读
victor8733
- 粉丝: 1
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 2022年中国足球球迷营销价值报告.pdf
- 房地产培训 -营销总每天在干嘛.pptx
- 黄色简约实用介绍_汇报PPT模板.pptx
- 嵌入式系统原理及应用:第三章 ARM编程简介_3.pdf
- 多媒体应用系统.pptx
- 黄灰配色简约设计精美大气商务汇报PPT模板.pptx
- 用matlab绘制差分方程Z变换-反变换-zplane-residuez-tf2zp-zp2tf-tf2sos-sos2tf-幅相频谱等等.docx
- 网络营销策略-网络营销团队的建立.docx
- 电子商务示范企业申请报告.doc
- 淡雅灰低面风背景完整框架创业商业计划书PPT模板.pptx
- 计算模型与算法技术:10-Iterative Improvement.ppt
- 计算模型与算法技术:9-Greedy Technique.ppt
- 计算模型与算法技术:6-Transform-and-Conquer.ppt
- 云服务安全风险分析研究.pdf
- 软件工程笔记(完整版).doc
- 电子商务网项目实例规划书.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0