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.pswp.cn/news/388771.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/388771.shtml
英文地址,請注明出處:http://en.pswp.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…

Spring boot 中pom.xml 各個節點詳解

<project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd "> <!-- 父項目的坐…

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 …

stack 的一些用法

#include<bits/stdc.h> using namespace std; int32_t main() {stack<int> st;st.push(1);st.push(2);st.push(3);cout<<st.size()<<endl;while(!st.empty()){cout<<st.top()<<endl;st.pop();} } 轉載于:https://www.cnblogs.com/Andromed…

IS環境下配置PHP5+MySql+PHPMyAdmin

IIS環境下配置PHP5MySqlPHPMyAdmin Posted on 2009-08-07 15:18 謝啟祥 閱讀(1385)評論(18) 編輯 收藏 雖然主要是做.net開發的&#xff0c;但是&#xff0c;時不時的還要搞一下php&#xff0c;但是&#xff0c;php在windows下的配置&#xff0c;總是走很多彎路&#xff0c;正好…

js復制功能

<div id"cardList"><div class"btn" onClick"copy(111)">點擊我&#xff0c;復制我</div></div> <script type"text/javascript"> function copy(str){var save function (e){e.clipboardData.setDa…

input在iOS里的兼容性

input框在iOS里&#xff0c;無法聚焦&#xff0c;不能輸入內容&#xff0c;把-webkit-user-select:none改成-webkit-user-select:auto;或者直接加一個style“-webkit-user-select:auto”.

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…

java用接口實例化對象_[求助]迷茫中,接口可以直接實例化對象嗎?

可能是我沒有寫完整吧,還是我沒有理解好1 接口public interface SetAndGetWeight{public void setW(double weight);public double getW();}2 類class Train{SetAndGetWeight[] things;public void Train(SetAndGetWeight[] things){this.thingsthings;}public void returnTota…

異常作業2(2018.08.22)

2、編寫程序接收用戶輸入分數信息&#xff0c;如果分數在0—100之間&#xff0c; 輸出成績。如果成績不在該范圍內&#xff0c; 拋出異常信息&#xff0c;提示分數必須在0—100之間。 要求&#xff1a;使用自定義異常實現1 import java.util.Scanner;2 3 class AtException ext…

深度學習數據集中數據差異大_使用差異隱私來利用大數據并保留隱私

深度學習數據集中數據差異大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#圖片處理基本應用(裁剪,縮放,清晰度,水印)

前言 需求源自項目中的一些應用&#xff0c;比如相冊功能&#xff0c;通常用戶上傳相片后我們都會針對該相片再生成一張縮略圖&#xff0c;用于其它頁面上的列表顯示。隨便看一下&#xff0c;大部分網站基本都是將原圖等比縮放來生成縮略圖。但完美主義者會發現一些問題&#…

java建立tcp服務器長連接_B/S 架構下后端能否建立 TCP 長連接?

這種架構下&#xff0c;這樣的優化策略能實現嗎&#xff1f;能有作用嗎&#xff1f;php 服務端請求 ES tcp server 部分代碼$streamClient stream_socket_client("tcp://{$tcpHost}:{$tcpPort}", $errno, $errstr);// 該數組是所有業務線的分類結構&#xff0c;及每…

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…