cayenne:用于随机模拟的Python包

TL;DR; We just released v1.0 of cayenne, our Python package for stochastic simulations! Read on to find out if you should model your system as a stochastic process, and why you should try out cayenne.

TL; DR; 我们刚刚发布了 cayenne v1.0 ,这是我们用于随机模拟的Python包! 请继续阅读以了解是否应该将系统建模为随机过程,以及为什么要尝试使用 cayenne

Mathematical models breathe structure into our understanding of the world. Oftentimes, they are cast as ordinary differential equations that describe how things change with time. In most cases, the insight from such models is sufficient for the question at hand. However, if you are trying to model the number of people who are going to be infected by SARS-CoV-2, a differential equation may not be the right tool for at least a couple of reasons:

数学模型为我们对世界的理解注入了结构。 通常,它们被转换为描述事物如何随时间变化的常微分方程。 在大多数情况下,来自此类模型的见解足以解决当前的问题。 但是,如果您要对将要感染SARS-CoV-2的人数进行建模,则至少有两个原因,微分方程可能不是正确的工具:

  1. Variables in differential equations are continuous and take values like 0.3, 2.7, etc. This isn’t ideal if you are talking about the number of people, which can only be integers like 1 or 2.

    微分方程中的变量是连续的,且取值为0.3、2.7等。如果您要谈论人数,那只能是1或2之类的整数,这并不理想。
  2. A differential equation always predicts the same output for a given input. However, not everyone who comes in contact with a COVID-19 infected person will develop the disease — the event is actually probabilistic, or stochastic.

    对于给定的输入,微分方程总是预测相同的输出。 但是,并非每个与COVID-19感染者接触的人都会患上这种疾病-该事件实际上是概率性的或随机的。

Let’s look at this with a concrete example. Infection and recovery from SARS-CoV-2 can be modeled with Susceptible-Infectious-Recovered (SIR) model. In this model, when an infectious person comes in contact with a susceptible person, the susceptible person gets infected and can now infect others. Eventually, the infected person recovers and cannot spread the disease anymore. These are represented by the equation below:

让我们看一个具体的例子。 SARS-CoV-2的感染和恢复可以用易感感染恢复(SIR)模型进行建模。 在此模型中,当感染者与易感者接触时,易感者会被感染,并且现在可以感染他人。 最终,感染者康复并且无法再传播疾病。 这些由以下等式表示:

Image for post
The infection and recovery process
感染和恢复过程

Giving some numbers for the parameters “k1” and “k2”, we can simulate the model as an ordinary differential equation in Python like this

给参数“ k1”和“ k2”一些数字,我们可以像使用Python这样将模型模拟为一个常微分方程。

If you plot the result of the simulation, it will look like this:

如果绘制模拟结果,它将看起来像这样:

Image for post
Simulating the SIR model with differential equations
用微分方程模拟SIR模型

You can see that i) the number of people is being represented by fractional values & ii) there is no notion of “probability” in the plot, it is just a smooth curve vs. time.

您可以看到,i)用分数值表示人数; ii)在图中没有“概率”的概念,它只是一条随时间变化的平滑曲线。

To address these limitations of differential equations, we use the more elegant built-for-purpose mathematical construct called a Markov jump process. Such a process is well suited for something like modeling the number of people. When the number of infected people increases from 5 to 6, there are instantaneous “jumps” between the integer values, instead of the gradual change (e.g. 5.1, 5.2, …, 6) seen in differential equations. Below we see the same SIR model from above, but simulated as a Markov jump process.

为了解决微分方程的这些局限性,我们使用了更为优雅的针对用途的内置数学构造,称为马尔可夫跳跃过程。 这样的过程非常适合于模拟人数。 当被感染人数从5增加到6时,整数值之间会出现瞬时“跳跃”,而不是微分方程式中出现的逐渐变化(例如5.1、5.2,…,6)。 在下面,我们从上方看到了相同的SIR模型,但以Markov跳跃过程进行了仿真。

Image for post
Simulating the SIR model with a Markov jump process
用Markov跳跃过程模拟SIR模型

The number of people in this Markov process jumps between integer values at random time-points, at a frequency determined the rate constants k1 and k2. The simulation stops when the number of infected individuals is zero, around time= 70 days. Repeating this simulation with a different random number seed gives a different simulation trajectory, but with the same general trend:

该马尔可夫过程中的人数在随机时间点的整数值之间跳跃,其频率确定为速率常数k1和k2。 当感染个体的数量为零时(大约70天左右),模拟停止。 使用不同的随机数种子重复此模拟将给出不同的模拟轨迹,但具有相同的总体趋势:

Image for post
Simulating a Markov jump process with a different seed
用不同的种子模拟Markov跳跃过程

Here we see that the infection ends quickly (t=25) as the number of infected individuals becomes zero sooner. Since each simulation trajectory is probabilistic, we generally run a large number of them to get an overall picture of the process.

在这里,我们看到感染很快结束(t = 25),因为被感染的人数很快变为零。 由于每个仿真轨迹都是概率性的,因此我们通常会运行大量仿真轨迹以获取整个过程的概况。

For simulating these Markov jump processes (also known as continuous-time Markov chains), we have developed an accurate, easy-to-use Python package called cayenne. You should be able to install it easily from here. And below is the minimal code for simulating the SIR model 10 times and plotting the simulation trajectories.

为了模拟这些Markov跳跃过程(也称为连续时间Markov链),我们开发了一个准确,易于使用的Python软件包,称为cayenne 。 您应该可以从这里轻松安装它。 下面是用于模拟SIR模型10次并绘制模拟轨迹的最小代码。

Image for post
Results of simulating the SIR model as a Markov jump process, 10 repetitions, on Cayenne
在Cayenne上将SIR模型作为Markov跳跃过程进行10次重复模拟的结果

If you are someone who runs stochastic simulations, we think you will enjoy trying out our package (get it here, examples here and a tutorial here) if you care about:

如果您是运行随机模拟的人,那么如果您关心以下方面,我们认为您会喜欢尝试一下我们的软件包的( 在此处获取示例, 在 此处提供示例,并在此处获得教程)。

  1. Accuracy: We tested all our algorithms for accuracy using the stochastic SBML test suite. Other packages that we tested were not as accurate as ours, as we find in our benchmarks.

    准确性 :我们使用随机SBML测试套件测试了所有算法的准确性。 正如我们在基准测试中发现的那样,我们测试的其他软件包的准确性不如我们的软件包。

  2. Fast code: Our backend is written in Cython for a nice balance between speed and ease of writing new algorithms. And different repetitions of the algorithm can be run across multiple CPU cores out of the box.

    快速代码 :我们的后端使用Cython编写,可以在速度和编写新算法的便利性之间取得很好的平衡。 而且该算法的不同重复可以在多个CPU核心中运行。

  3. Quick prototyping: We leverage the cool antimony library to provide an easy and intuitive model writing interface. There is no need to write out the stoichiometric matrices.

    快速原型制作 :我们利用出色的锑库提供简单直观的模型编写界面。 无需写出化学计量矩阵。

  4. The little things: Stochastic simulations usually mean outputs logged at stochastic time points (e.g. at t = 19.3, 19.7). But with cayenne, you can get an accurately interpolated value at the time points of your choice (e.g. at t = 19.5).

    小事情 :随机模拟通常意味着在随机时间点记录的输出(例如,在t = 19.3,19.7时)。 但是,使用cayenne ,您可以在选择的时间点获得准确的插值(例如,t = 19.5)。

We’d love for you to check out our package and let us know what you think! Currently, we are writing up a manuscript.

我们希望您能检查我们的包裹,并告诉我们您的想法! 目前,我们正在编写手稿。

翻译自: https://medium.com/heuro-labs/cayenne-a-python-package-for-stochastic-simulations-3807dc4398f5

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/388771.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

java 如何将word 转换为ftl_使用 freemarker导出word文档

近日需要将人员的基本信息导出,存储为word文档,查阅了很多资料,最后选择了使用freemarker,网上一共有四种方式,效果都一样,选择它呢是因为使用简单,再次记录一下,一个简单的demo,仅供…

DotNetBar office2007效果

1.DataGridView 格式化显示cell里的数据日期等。 进入编辑列,选择要设置的列,DefaultCellStyle里->行为->formart设置 2.tabstrip和mdi窗口的结合使用给MDI窗口加上TabPage。拖动个tabstrip到MDI窗口上tabstrip里选择到主窗口名就加上TABPAGE了。d…

spotify 数据分析_没有数据? 没问题! 如何从Wikipedia和Spotify收集重金属数据

spotify 数据分析For many data science students, collecting data is seen as a solved problem. It’s just there in Kaggle or UCI. However, that’s not how data is available daily for working Data Scientists. Also, many of the datasets used for learning have …

IS环境下配置PHP5+MySql+PHPMyAdmin

IIS环境下配置PHP5MySqlPHPMyAdmin Posted on 2009-08-07 15:18 谢启祥 阅读(1385)评论(18) 编辑 收藏 虽然主要是做.net开发的,但是,时不时的还要搞一下php,但是,php在windows下的配置,总是走很多弯路,正好…

kaggle数据集_Kaggle上有170万份ArXiv文章的数据集

kaggle数据集“arXiv is a free distribution service and an open-access archive for 1.7 million scholarly articles in the fields of physics, mathematics, computer science, quantitative biology, quantitative finance, statistics, electrical engineering and sys…

深度学习数据集中数据差异大_使用差异隐私来利用大数据并保留隐私

深度学习数据集中数据差异大The modern world runs on “big data,” the massive data sets used by governments, firms, and academic researchers to conduct analyses, unearth patterns, and drive decision-making. When it comes to data analysis, bigger can be bett…

C#图片处理基本应用(裁剪,缩放,清晰度,水印)

前言 需求源自项目中的一些应用,比如相册功能,通常用户上传相片后我们都会针对该相片再生成一张缩略图,用于其它页面上的列表显示。随便看一下,大部分网站基本都是将原图等比缩放来生成缩略图。但完美主义者会发现一些问题&#…

Java客户端访问HBase集群解决方案(优化)

测试环境&#xff1a;IdeaWindows10 准备工作&#xff1a; <1>、打开本地 C:\Windows\System32\drivers\etc&#xff08;系统默认&#xff09;下名为hosts的系统文件&#xff0c;如果提示当前用户没有权限打开文件&#xff1b;第一种方法是将hosts文件拖到桌面进行配置后…

WPF布局系统

WPF之路——WPF布局系统 前言 前段时间忙了一阵子Google Earth&#xff0c;这周又忙了一阵子架构师论文开题报告&#xff0c;现在终于有时间继续<WPF之路>了。先回忆一下上篇的内容&#xff0c;在《从HelloWorld到WPF World》中&#xff0c;我们对WPF有了个大概的了解&am…

PostGIS容器运行

2019独角兽企业重金招聘Python工程师标准>>> 获取镜像&#xff1a; docker pull mdillon/postgis 该 mdillon/postgis 镜像提供了容器中运行Postgres&#xff08;内置安装PostGIS 2.5&#xff09; 。该镜像基于官方 postgres image&#xff0c;提供了多种变体&#…

小型数据库_如果您从事“小型科学”工作,那么您是否正在利用数据存储库?

小型数据库If you’re a scientist, especially one performing a lot of your research alone, you probably have more than one spreadsheet of important data that you just haven’t gotten around to writing up yet. Maybe you never will. Sitting idle on a hard dri…

BitmapEffect位图效果是简单的像素处理操作。它可以呈现下面几种特殊效果。

BitmapEffect位图效果是简单的像素处理操作。它可以呈现下面几种特殊效果。 BevelBitmapEffect 凹凸效果 BlurBitmapEffect 模糊效果 DropShadowBitmapEffect投影效果 EmbossBitmapEffect 浮雕效果 Outer…

AutoScaling 与函数计算结合,赋予更丰富的弹性能力

目前&#xff0c;弹性伸缩服务已经接入了负载均衡&#xff08;SLB&#xff09;、云数据库RDS 等云产品&#xff0c;但是暂未接入 云数据库Redis&#xff0c;有时候我们可能会需要弹性伸缩服务在扩缩容的时候自动将扩缩容涉及到的 ECS 实例私网 IP 添加到 Redis 白名单或者从 Re…

参考文献_参考

参考文献Recently, I am attracted by the news that Tanzania has attained lower middle income status under the World Bank’s classification, five years ahead of projection. Being curious on how they make the judgement, I take a look of the World Bank’s offi…

数据统计 测试方法_统计测试:了解如何为数据选择最佳测试!

数据统计 测试方法This post is not meant for seasoned statisticians. This is geared towards data scientists and machine learning (ML) learners & practitioners, who like me, do not come from a statistical background.Ť他的职位是不是意味着经验丰富的统计人…

spring的几个通知(前置、后置、环绕、异常、最终)

1、没有异常的 2、有异常的 1、被代理类接口Person.java 1 package com.xiaostudy;2 3 /**4 * desc 被代理类接口5 * 6 * author xiaostudy7 *8 */9 public interface Person { 10 11 public void add(); 12 public void update(); 13 public void delete();…

每个Power BI开发人员的Power Query提示

If someone asks you to define the Power Query, what should you say? If you’ve ever worked with Power BI, there is no chance that you haven’t used Power Query, even if you weren’t aware of it. Therefore, one could easily say that Power Query is the “he…

c# PDF 转换成图片

1.新建项目 2.新增一个新文件夹“lib”&#xff08;主要是为了存放引用的dll&#xff09; 3.将“gsdll32.dll 、PDFLibNet.dll 、PDFView.dll”3个dll添加到文件夹中 4.项目添加“PDFLibNet.dll 、PDFView.dll”2个类库的引用&#xff0c;并将gsdll32.dll 拷贝到项目生产根…

oracle 死锁

为什么80%的码农都做不了架构师&#xff1f;>>> ORA-01013: user requested cancel of current operation 转载于:https://my.oschina.net/8808/blog/2994537

a/b测试_如何进行A / B测试?

a/b测试The idea of A/B testing is to present different content to different variants (user groups), gather their reactions and user behaviour and use the results to build product or marketing strategies in the future.A / B测试的想法是将不同的内容呈现给不同…