Code Monkey home page Code Monkey logo

spatio-temporal-point-process-simulator's Introduction

Marked Spatio-Temporal Point Process Simulator

A set of Python tools called STPPG for simulating any form of Marked Spatio-temporal self-exciting point processes.

Usage

There are two vital files included in this repo:

  • stppg.py basic generators for homogeneous and inhomogeneous univariate point process, as well as different kinds of intensity classes and kernel functions.
  • utils.py Some simple plotting functions for visualizing the point process simulation.

For simulating any parametric point process defined in references, we need to define the parametric form of its conditional density and generating space (time, location, and marks).

  • To define the form of the conditional density of a point process, a Lam object defined in stppg.py has to be substantiated with corresponding parameters. The most important parameters of a conditional intensity Lam is defined in its kernel function. See the example below.
  • Regard the space of the point process, time space is specified by 1D two-elements list T, and location & mark space is jointly specified by 2D list S, where first two sub-lists indicate the location X and Y, and the following sub-lists indicate the mark space.

Examples

A simple example for simulating a spatio-temporal hawkes point process equipped with a standard diffusion kernel by using stppg.

from stppg import StdDiffusionKernel, HawkesLam, MarkedSpatialTemporalPointProcess
from utils import plot_spatio_temporal_points, plot_spatial_intensity

np.random.seed(0)
np.set_printoptions(suppress=True)

# parameters initialization
mu     = .1
kernel = StdDiffusionKernel(C=1., beta=1., sigma_x=.1, sigma_y=.1)
lam    = HawkesLam(mu, kernel, maximum=1e+3)
pp     = SpatialTemporalPointProcess(lam)

# generate points
points, sizes = pp.generate(
    T=[0., 10.], S=[[-1., 1.], [-1., 1.]], 
    batch_size=500, verbose=True)

# plot intensity of the process over the time
plot_spatial_intensity(lam, points[0], S=[[0., 10.], [-1., 1.], [-1., 1.]],
    t_slots=1000, grid_size=50, interval=50)

And see the console output below.

[2018-09-21T08:28:59.974629-04:00] generate samples (10167, 3) from homogeneous poisson point process
[2018-09-21T08:28:59.975163-04:00] 0 raw samples have been checked. 0 samples have been retained.
[2018-09-21T08:29:00.097072-04:00] 1000 raw samples have been checked. 1 samples have been retained.
[2018-09-21T08:29:00.327207-04:00] 2000 raw samples have been checked. 11 samples have been retained.
[2018-09-21T08:29:00.643629-04:00] 3000 raw samples have been checked. 21 samples have been retained.
[2018-09-21T08:29:01.061958-04:00] 4000 raw samples have been checked. 51 samples have been retained.
[2018-09-21T08:29:01.592077-04:00] 5000 raw samples have been checked. 71 samples have been retained.
[2018-09-21T08:29:02.242894-04:00] 6000 raw samples have been checked. 88 samples have been retained.
[2018-09-21T08:29:02.974756-04:00] 7000 raw samples have been checked. 100 samples have been retained.
[2018-09-21T08:29:03.779483-04:00] 8000 raw samples have been checked. 110 samples have been retained.
[2018-09-21T08:29:04.741294-04:00] 9000 raw samples have been checked. 128 samples have been retained.
[2018-09-21T08:29:05.729931-04:00] 10000 raw samples have been checked. 146 samples have been retained.
[2018-09-21T08:29:05.904117-04:00] thining samples (147, 3) based on Spatio-temporal Hawkes point process intensity with mu=0, beta=1 and Diffusion-type Kernel.
[[0.06299644 0.9183208  0.97126597]
 [0.11153312 0.280956   0.05509999]
 [0.121267   0.36991751 0.65443569]
 [0.12390124 0.49035887 0.64267112]
 [0.13272256 0.9463777  0.02484997]
     ... ...
 [0.97093684 0.13255896 0.15690197]
 [0.97663217 0.6115613  0.34787382]
 [0.97863127 0.21207182 0.19613095]
 [0.98051828 0.43338621 0.67951877]
 [0.99105454 0.21976152 0.26218951]]
[2018-09-21T08:29:05.911032-04:00] preparing the dataset 1000 ร— (50, 50) for plotting.
[2018-09-21T08:32:26.300910-04:00] start animation.

The animations below show the progression of conditional intensities through time with different types of kernel functions.

Standard Diffusion Kernel Gaussian Diffusion Kernel Gaussian Mixture Diffusion Kernel

References

spatio-temporal-point-process-simulator's People

Contributors

meowoodie avatar

Watchers

 avatar  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.