Skip to main content

Fast intensity inference

Project description


authors: Thomas A. Lasko, Jacek Bajor, John Still


Fast density inference. Generates intensity curves from given events.


We only support Python 3 and above. We recommend using fast_intensity in a virtual environment; however, if you choose to install to a system-wide version of Python, be aware that some distributions will alias Python 3's pip as pip3. You should be able to verify which Python pip is associated with by running pip --version.

If you prefer to install a precompiled binary, we provide wheels for OS X and Linux (via the manylinux project). The basic pip install command line

$ pip install fast-intensity

should prefer one of our prebuilt binaries. Installation from source requires an environment with Cython, numpy, and scipy preinstalled.

$ pip install cython numpy scipy

Then you may install a release from source by specifying not to use a binary:

$ pip install fast-intensity --no-binary fast-intensity

(Yes, it is necessary to specify fast-intensity twice.) Alternately, to install the bleeding edge version:

$ git clone
$ cd fast-intensity
$ pip install -e .


%matplotlib inline
%load_ext cython
import matplotlib.pyplot as plt
import numpy as np
import datetime as dt
# If working locally rather than from a wheel or other binary
import pyximport
from fast_intensity import infer_intensity


# Specify a series of 100 events spread over a year
days = np.arange(0.0, 365)
events = np.sort(days[:100])

# Specify times (as reals) where we want to calculate the intensity of event occurrence
grid = np.linspace(1, 365, num=12)

# Generate the intensity curve - the unit is events per time unit
curve = infer_intensity(events, grid)
#     array([0.38953   , 0.27764734, 0.33549508, 0.27285165, 0.22284481, 0.16997545,
#            0.26651725, 0.23580527, 0.23351076, 0.25272662, 0.33146159, 0.28486727])'ggplot')
fig, ax = plt.subplots(figsize=(9,9))
ax.scatter(events, np.zeros(len(events)), alpha='0.4', label='Events')
ax.scatter(grid, np.zeros(len(grid)) + 0.025, label='Grid')
ax.plot(grid, curve, label='Intensity')

You can see how the intensity graph dips in the middle, where events are more thinly spaced, and rises near the beginning (where we have a high density of events).


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for fast-intensity, version 0.4
Filename, size File type Python version Upload date Hashes
Filename, size fast_intensity-0.4-cp35-cp35m-manylinux1_x86_64.whl (343.0 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size fast_intensity-0.4-cp36-cp36m-manylinux1_x86_64.whl (351.9 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size fast_intensity-0.4-cp37-cp37m-macosx_10_9_x86_64.whl (113.4 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size fast_intensity-0.4-cp37-cp37m-manylinux1_x86_64.whl (351.8 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size fast-intensity-0.4.tar.gz (163.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page