Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieving Max Lifespan from Rips #91

Closed
aflytle opened this issue Feb 8, 2020 · 1 comment
Closed

Retrieving Max Lifespan from Rips #91

aflytle opened this issue Feb 8, 2020 · 1 comment

Comments

@aflytle
Copy link

aflytle commented Feb 8, 2020

I'm relatively new to TDA, so forgive some uninformed sounding wording.

In the Ripser.py implementation, I see that we are using the C++ structs for the arrays of points.
Is there any way to (still in Python) retrieve the maximum lifespan of some points in the persistence diagram/barcodes? I.E., is there a way to find the maximum lifespan of a point in a point cloud, when running the rips complex persistence homology on it?

I need to find the two longest lifespans in the dataset.

Respectfully,
Aidan Lytle

@ctralie
Copy link
Member

ctralie commented Feb 17, 2020

Hello,
Thank you for your patience on our response. Here's an example of how one might do this:

import numpy as np
from ripser import ripser
X = np.random.randn(100, 20) # Make a random point cloud with 100 points in 20 dimensions
dgms = ripser(X)['dgms'] # Pull out the diagrams (by default up to H1)
H1 = dgms[1] # Look at H1
H1 = H1[np.argsort(H1[:, 0] - H1[:, 1]), :] # Sort the points in descending order of persistence
lifespans = H1[:, 1] - H1[:, 0] # Now we have the lifespans in decreasing order

@ctralie ctralie closed this as completed Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants