Fast intensity inference
Project description
fast-intensity
authors: Thomas A. Lasko, Jacek Bajor, John Still
Overview
Fast density inference. Generates intensity curves from given events.
Installation
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 https://github.com/ComputationalMedicineLab/fast-intensity.git
$ cd fast-intensity
$ pip install -e .
Usage
%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
pyximport.install(language_level=3)
from fast_intensity import infer_intensity
np.random.seed(42)
# Specify a series of 100 events spread over a year
days = np.arange(0.0, 365)
np.random.shuffle(days)
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)
print(curve)
# 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, curve, 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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fast-intensity-0.4.tar.gz.
File metadata
- Download URL: fast-intensity-0.4.tar.gz
- Upload date:
- Size: 163.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a4b95d73c8dd075afb48b97ce88776400c445cac82d78fdcfd8b8c08ad8670f
|
|
| MD5 |
9ed6189bb55af838de49d12d18e54589
|
|
| BLAKE2b-256 |
a034d1c5d1bf0248a082797fd490bbc1127cefb430add3fe9350131614e61072
|
File details
Details for the file fast_intensity-0.4-cp37-cp37m-manylinux1_x86_64.whl.
File metadata
- Download URL: fast_intensity-0.4-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 351.8 kB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9425e5c6520b4893aabda23fb25940d01beaf9b71361630f74479472ee86ffd6
|
|
| MD5 |
12e21dac1ada10cbb521f03b95a42320
|
|
| BLAKE2b-256 |
c0ba6f61389c57e262f82ecdb2426b2b939ec171c8b1e7945a5e26cea57dbbed
|
File details
Details for the file fast_intensity-0.4-cp37-cp37m-macosx_10_9_x86_64.whl.
File metadata
- Download URL: fast_intensity-0.4-cp37-cp37m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 113.4 kB
- Tags: CPython 3.7m, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a99b2c4e1e520079d06b9d9ed6811fa2bb76ac2e2648d7516cd8e56fe2df816
|
|
| MD5 |
ed429510c915c50293f49a2359155330
|
|
| BLAKE2b-256 |
f185c905116a5c6cadd2f3cc6877ff7b505479e7d36ce34df9926ca99865f171
|
File details
Details for the file fast_intensity-0.4-cp36-cp36m-manylinux1_x86_64.whl.
File metadata
- Download URL: fast_intensity-0.4-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 351.9 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc7092a2016e5753ebb9c06c01555fb4283f2355a690d36cb78029dbe6a90c70
|
|
| MD5 |
84dbd9960ee6609e73c0545a03a1a2bd
|
|
| BLAKE2b-256 |
ecdaccee16286050af55e49273c584074e7dc44b79638365495f4ea40a5cf835
|
File details
Details for the file fast_intensity-0.4-cp35-cp35m-manylinux1_x86_64.whl.
File metadata
- Download URL: fast_intensity-0.4-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 343.0 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11e24286bac97fbd8b430c46caa3c3ef89a581e4cad48914db162f7157e51b07
|
|
| MD5 |
8a95373f207e42d1cbb5f5155465d23a
|
|
| BLAKE2b-256 |
af6e3d3ceb99182c5376c3d105d5537d239b6fdd88773ca658ae4e7ed0ba60fc
|