Giter Site home page Giter Site logo

nsim's People

Contributors

mattja avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nsim's Issues

plot time scale are wrong

When you plot a simulation with timeseries.plot(),
the time axis is not scaled correctly.

if you run a simulation like this:

sim = nsim.RepeatedSim(Model, T=100, repeat=2)
sim.timeseries.plot()

The time scale of the plot should go from 0 to 100, right?.

Incompatibility with ipyparallel>=5.0

nsim works fine with ipyparallel 4 and earlier, but gives spurious messages with ipyparallel 5.0.x and breaks with ipyparallel >=5.1.x, working some of the time, and completely freezing with no error message at other times. See mattja/distob#3.

Have not yet investigated this to find whether this is a bug in ipyparallel or distob, or whether it results from a change to the AsyncResult interface in ipyparallel.
Until this issue is sorted out, temporarily require ipyparallel 4.x

Problem simulating a 2 dimensional system

Hi, I am trying to use nsim to simulate the following model:

"""
SIR Epidemic Model

S --> I --> R

X(t) = [S(t), I(t)]

Equations:

dS = -r0*S*I dt -sqrt(r0*S*I) dW1
dI = r0*S*I dt + sqrt(r0*S*I) dW1 -sqrt(I) dW2

"""

import nsim
import numpy as np

class SIR(nsim.ItoModel):
    r0 = 1.5
    y0 = np.array([0.9, 0.1]).T

    def f(self, y, t):
        A = np.array([[-self.r0*y[0]*y[1]],
                       [self.r0*y[0]*y[1] - y[1]]])
        return A

    def G(self, y, t):
        B = np.array([[-np.sqrt(self.r0*y[0]*y[1]), 0],
                       [np.sqrt(self.r0*y[0]*y[1]), - y[1]]])
        return B

To simulate it I tried the following:

s = nsim.Simulation(SIR, T=520.0)

It seems to work but when I try to plot the results, I get this error:

Traceback (most recent call last):
  File "SDE_SIR.py", line 38, in <module>
    print(s.output, dir(s))
  File "/usr/local/lib/python3.5/dist-packages/nsim/nsim.py", line 1330, in output
    self.compute()
  File "/usr/local/lib/python3.5/dist-packages/nsim/nsim.py", line 1313, in compute
    ar = self.system.integrate(tspan)
  File "/usr/local/lib/python3.5/dist-packages/nsim/nsim.py", line 870, in integrate
    ar = self.integrator[0](self.f, self.G, self.y0, tspan)
  File "/usr/local/lib/python3.5/dist-packages/sdeint/integrate.py", line 125, in itoint
    return chosenAlgorithm(f, G, y0, tspan)
  File "/usr/local/lib/python3.5/dist-packages/sdeint/integrate.py", line 305, in itoSRI2
    return _Roessler2010_SRK2(f, G, y0, tspan, Imethod, dW, I)
  File "/usr/local/lib/python3.5/dist-packages/sdeint/integrate.py", line 439, in _Roessler2010_SRK2
    H20b = np.reshape(H20, (d, 1))
  File "/usr/local/lib/python3.5/dist-packages/numpy/core/fromnumeric.py", line 225, in reshape
    return reshape(newshape, order=order)
ValueError: total size of new array must be unchanged

Is this a bug, or maybe a mistake in my model?

Python 3 compatibility

I don't know if you already support python 3, but I noticed the follwing exception when trying to run one of the examples under Python3:

   import nsim
  File "/usr/local/lib/python3.5/dist-packages/nsim/__init__.py", line 5, in <module>
    from . import analyses1
  File "/usr/local/lib/python3.5/dist-packages/nsim/analyses1/__init__.py", line 12, in <module>
    from .pyeeg import (hurst, embed_seq, in_range, bin_power, pfd, hfd, hjorth,
  File "/usr/local/lib/python3.5/dist-packages/nsim/analyses1/pyeeg.py", line 161
    print "Cannot build such a matrix, because D * Tau > N"
                                                          ^
SyntaxError: Missing parentheses in call to 'print'

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.