tdads.PH_utils

Functions

enclosing_radius(X[, distance_mat])

Compute the enclosing radius of a dataset. Beyond this filtration radius no

Module Contents

tdads.PH_utils.enclosing_radius(X: numpy.ndarray, distance_mat: bool = False)[source]

Compute the enclosing radius of a dataset. Beyond this filtration radius no topological changes can occur.

Parameters:
  • X (numpy.ndarray (2D)) – The input dataset - either raw tabular data or a distance matrix of samples.

  • distance_mat (bool, default False) – Whether or not X is a distance matrix. If False then a Euclidean distance matrix will be computed.

Returns:

The enclosing radius value of X.

Return type:

numpy.float64

Examples

>>> from tdads.PH_utils import enclosing_radius
>>> from ripser import ripser
>>> from numpy.random import uniform
>>> from numpy import array, cos, sin
>>> from math import pi
>>> from scipy.spatial.distance import cdist
>>> # build circle dataset
>>> theta = uniform(low = 0, high = 2*pi, size = 100)
>>> data = array([[cos(theta[i]), sin(theta[i])] for i in range(100)])
>>> # compute the enclosing radius
>>> enc_rad = enclosing_radius(data)
>>> # compute persistence diagram
>>> diagram = ripser(data, enc_rad)
>>> # now for a distance matrix
>>> dist_data = cdist(data, data, 'euclidean')
>>> enc_rad = enclosing_radius(dist_data, True)
>>> diagram = ripser(dist_data, enc_rad, distance_matrix = True)