|
Teetool
Probabilistic modelling of trajectories
|
Functions | |
| def | getDistinctColours (ncolours, colour=None) |
| a function to obtain n distinct colours (based on the colourspace spread into hue space), inspired by https://stackoverflow.com/questions/470690/how-to-automatically-generate-n-distinct-colors More... | |
| def | find_nearest (original_values, target_values) |
| function to find nearest values in an array, perfect for reducing the number of datapoints More... | |
| def | nearest_spd (A) |
| nearestSPD - the nearest (in Frobenius norm) Symmetric Positive Definite matrix to A More... | |
| def | get_trajectories (ntype=0, ndim=3, ntraj=50, npoints=100, noise_std=.5) |
| function to generate some distributed trajectories More... | |
| def | in_hull (p, hull) |
Test if points in p are in hull More... | |
| def | unique_rows (a) |
| function to find unique rows More... | |
| def | gauss_logp (y, ndim, c, A) |
| function to evaluate the Gaussian log likelihood More... | |
| def | gauss (y, ndim, c, A) |
| function to evaluate the Gaussian (normal distribution) More... | |
| def | gauss_logLc (y, ndim, cc, cA) |
| function to evaluate the Gaussian log likelihood in cell-form More... | |
| def | getMaxOutline (ndim) |
| simple function to obtain infinite outline based on dimensionality More... | |
| def | getGridFromResolution (outline, resolution) |
| function to generate a grid based on outline and resolution More... | |
| def | getDimension (cluster_data) |
| finds dimension D based on cluster_data More... | |
| def | getMinMax (cluster_data) |
| find minimum/maximum of the cluster data (x, Y), x-component. More... | |
| def | normalise_data (cluster_data) |
| normalise the cluster_data in x-domain More... | |
| def | getNorm (x, tuple_min_max) |
| returns a normalised array based on a specified minimum/maximum More... | |
| def | get_cluster_data_outline (cluster_data) |
| returns the outline based on cluster_data More... | |
| def | get_cluster_data_norm (cluster_data, outline=None) |
| returns a normalised cluster_data based on outline More... | |
| def teetool.helpers.find_nearest | ( | original_values, | |
| target_values | |||
| ) |
function to find nearest values in an array, perfect for reducing the number of datapoints
| original_values | an array of original values |
| target_values | an array of desired values |
| def teetool.helpers.gauss | ( | y, | |
| ndim, | |||
| c, | |||
| A | |||
| ) |
function to evaluate the Gaussian (normal distribution)
| y | data-point |
| ndim | dimensionality of y |
| c | mean vector |
| A | convariance matrix |
| def teetool.helpers.gauss_logLc | ( | y, | |
| ndim, | |||
| cc, | |||
| cA | |||
| ) |
function to evaluate the Gaussian log likelihood in cell-form
| y | data-point |
| ndim | dimensionality of y |
| cc | mean vector cells |
| cA | convariance matrix cells |
returns the log likelihood of a position based on model (in cells)
| def teetool.helpers.gauss_logp | ( | y, | |
| ndim, | |||
| c, | |||
| A | |||
| ) |
function to evaluate the Gaussian log likelihood
| y | data-point |
| ndim | dimensionality of y |
| c | mean vector |
| A | convariance matrix |
| def teetool.helpers.get_cluster_data_norm | ( | cluster_data, | |
outline = None |
|||
| ) |
returns a normalised cluster_data based on outline
| cluster_data | list of (x, Y) trajectory data |
| outline | array specifying an pre-set outline, otherwise the outline is calculated from the cluster_data |
specifying an outline is useful when wanting to normalise based on multiple clusters
| def teetool.helpers.get_cluster_data_outline | ( | cluster_data | ) |
returns the outline based on cluster_data
| cluster_data | list of (x, Y) trajectory data |
| def teetool.helpers.get_trajectories | ( | ntype = 0, |
|
ndim = 3, |
|||
ntraj = 50, |
|||
npoints = 100, |
|||
noise_std = .5 |
|||
| ) |
function to generate some distributed trajectories
| ntype | type of trajectory (0 or 1) |
| ndim | dimensionality of trajectories (2 or 3) |
| ntraj | number of trajectories desired |
| npoints | how many points each trajectory has |
| noise_std | includes normal distributed (Gaussian) noise to the trajectory data-points return cluster_data a list of (x, Y) trajectory data |
| def teetool.helpers.getDimension | ( | cluster_data | ) |
finds dimension D based on cluster_data
| cluster_data | list of (x, Y) format |
| def teetool.helpers.getDistinctColours | ( | ncolours, | |
colour = None |
|||
| ) |
a function to obtain n distinct colours (based on the colourspace spread into hue space), inspired by https://stackoverflow.com/questions/470690/how-to-automatically-generate-n-distinct-colors
| ncolours | integer with number of distinct colours |
| colour | when colour is specified, this overrides any distinct colour |
| def teetool.helpers.getGridFromResolution | ( | outline, | |
| resolution | |||
| ) |
function to generate a grid based on outline and resolution
| outline | [ndim x 2], minimum and maximum values |
| resolution | can be a scalar [1x1] or specified per dimension [ndim x 1] |
| def teetool.helpers.getMaxOutline | ( | ndim | ) |
simple function to obtain infinite outline based on dimensionality
| ndim | number of dimensions |
| def teetool.helpers.getMinMax | ( | cluster_data | ) |
find minimum/maximum of the cluster data (x, Y), x-component.
The tuple is used to normalise the data
| cluster_data | list of (x, Y) |
| def teetool.helpers.getNorm | ( | x, | |
| tuple_min_max | |||
| ) |
returns a normalised array based on a specified minimum/maximum
| x | input array |
| tuple_min_max | a tuple with minimum and maximum specified |
| def teetool.helpers.in_hull | ( | p, | |
| hull | |||
| ) |
Test if points in p are in hull
| p | an array of points |
| hull | points for hull, if not hull, make a hull from points |
p should be a NxK coordinates of N points in K dimensions hull is either a scipy.spatial.Delaunay object or the MxK array of the coordinates of M points in Kdimensions for which Delaunay triangulation will be computed
| def teetool.helpers.nearest_spd | ( | A | ) |
nearestSPD - the nearest (in Frobenius norm) Symmetric Positive Definite matrix to A
| A | input matrix |
nearestSPD - the nearest (in Frobenius norm) Symmetric Positive Definite matrix to A usage: Ahat = nearestSPD(A)
From Higham: "The nearest symmetric positive semidefinite matrix in the Frobenius norm to an arbitrary real matrix A is shown to be (B + H)/2, where H is the symmetric polar factor of B=(A + A')/2."
http://www.sciencedirect.com/science/article/pii/0024379588902236
arguments: (input) A - square matrix, which will be converted to the nearest Symmetric Positive Definite Matrix.
Arguments: (output) Ahat - The matrix chosen as the nearest SPD matrix to A.
RE-CODED FROM MATLAB nearestSPD http://uk.mathworks.com/matlabcentral/fileexchange/42885-nearestspd
| def teetool.helpers.normalise_data | ( | cluster_data | ) |
normalise the cluster_data in x-domain
| cluster_data | list of (x, Y) data |
| def teetool.helpers.unique_rows | ( | a | ) |
function to find unique rows
| a | matrix |
https://stackoverflow.com/questions/16970982/find-unique-rows-in-numpy-array
1.8.12