Fast intensity inference
Project description
fast-intensity
authors: Thomas A. Lasko, Jacek Bajor
Overview
Fast density inference. Generates intensity curves from given events.
Installation
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 and numpy preinstalled.
$ pip install cython numpy
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 https://github.com/ComputationalMedicineLab/fast-intensity.git
$ cd fast-intensity
$ pip install -e .
Usage
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import datetime as dt
from fast_intensity import FastIntensity
np.random.seed(42)
# Specify a series of 100 events spread over a year
days = np.arange(0, 365)
np.random.shuffle(days)
events = sorted(days[:100])
# Specify times (as reals) where we want to calculate the intensity of event occurrence
grid = np.linspace(1, 365, num=12)
# Configure a FastIntensity instance with the events and the grid
curve_builder = FastIntensity(events, grid)
# Generate the intensity curve - the unit is events per time unit
intensity = curve_builder.run_inference()
print(intensity)
# 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])
plt.style.use('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, intensity, label='Intensity')
plt.legend()
plt.show()
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.
Source Distribution
Built Distributions
Hashes for fast_intensity-0.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cc87050bf6d3c9ceb0a1bd30585ca107ad8cb1fbc315ed3c728035ef67c30a5 |
|
MD5 | 24cd229569ab4b83f34b62f51b584030 |
|
BLAKE2b-256 | 42c4df12b99ecd37658be24a644dad9d47df29976267e2d597fab6d97fcb0517 |
Hashes for fast_intensity-0.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04e97e4ace9a8bacd35cdaa538298a12c542109f645929053d6ac403f4f12bd3 |
|
MD5 | e6150621ba0589324405fce12a387f34 |
|
BLAKE2b-256 | 9c26d3c5b5f766c45289e4b897c207e70db574f6543412ab5610905e3babb9fa |
Hashes for fast_intensity-0.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efe51c5f6dae92ac7c7c63bffd7fa9cb805ddc1c5423f626b299bc991882f3b7 |
|
MD5 | 5bba973371ef8b72b8b70dae63037883 |
|
BLAKE2b-256 | 2d03a25fba74283ddcf23d20978b2fd88c9766213afa602d54d3fd3943b08030 |
Hashes for fast_intensity-0.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d20a9665478bb0851aa8a99382a95161a3b9c9d76c624bee3c4e96c40a1b7b70 |
|
MD5 | 891155adf2f9af725434acb30d592708 |
|
BLAKE2b-256 | 816c8b25940dbc46d11f8ae0cfb8640e894a33d743ba1d9b7f4fa7deadb7ee7f |