Giter Site home page Giter Site logo

pdmpsim's Introduction

pdmpsim

The goal of pdmpsim is to simulate piecewise deterministic markov processes (PDMPs) within R and to provide methods for analysing the simulation results.

It is possible to

  • simulate pdmps
  • store multiple simulations in a convenient way
  • calculate some statistics on them
  • plot the results (there are different plot methods available)
  • compute the generator

The PDMPs can have multiple discrete and continous variables, but are not allowed to have borders or a varying number of continous variables (the number should be independent of the state of the discrete variable).

Installation

You can install pdmpsim from github with:

# install.packages("devtools")
devtools::install_github("CharlotteJana/pdmpsim")

Example

This is a simple example modelling gene expression with positive feedback:

examplePDMP <- pdmpModel(
  descr = "Gene regulation with positive feedback",
  parms = list= 0.2, α = 7, κ10 = 0.04, κ01 = 0.02),
  init = c(f = 1, d = 1),
  discStates = list(d = c(0, 1)),
  dynfunc = function(t, x, parms) {
    df <- with(as.list(c(x, parms)), α*d - β*f)
    return(c(df, 0))
  },
  ratefunc = function(t, x, parms) {
    return(with(as.list(c(x, parms)), switch(d + 1, κ01*f, κ10)))
  },
  jumpfunc = function(t, x, parms, jtype) {
    c(x[1], 1 - x[2])
  },
  times = c(from = 0, to = 100, by = 0.1),
  solver = "lsodar")

Perform one simulation and plot the result:

examplePDMP <- sim(examplePDMP)
plot(examplePDMP)

Simulate multiple times and store the result:

simulations <- multSim(examplePDMP, seeds = 1:30)

Plot the simulations:

plot(simulations)
plotTimes(simulations, vars = "f", times = c(60, 90, 100))
density(simulations, t = c(60, 90, 100))
plotSeeds(simulations, seeds = c(1, 30))

Calculate minimum, mean and maximum and plot them:

summarise_at(simulations, .vars = "f", .funs = c("min", "mean", "max"))
plotStats(simulations, vars = "f", funs = c("min", "mean", "max"))

pdmpsim's People

Contributors

charlottejana avatar hvlieb avatar

Watchers

Moritz Schmidt avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.