Skip to content

Incorrect diagrams returned from ripsDiag() using distance matrices as input. #31

@jordanschupbach

Description

@jordanschupbach

There seems to be a bug in how the ripsDiag() function calculates persistence diagrams when using a distance matrix as input. The following code illustrates this bug:

    sphere_points <- matrix(c(-1, 0,  0, 1, 0, 0, 0, -1, 0,
                               0, 1, 0, 0,  0, -1, 0, 0, 1),
                            nrow = 6, ncol = 3)
  
    # Use distance matrix for sphere
    diag1 <- ripsDiag(dist(sphere_points), maxdimension = 2,
                      maxscale = 5, dist = "arbitrary")
  
    # Use distance  matrix
    diag2 <- ripsDiag(sphere_points, maxdimension = 2,
                      maxscale = 5, dist = "euclidean")
  
diag1$diagram
     dimension Birth    Death
[1,]         0     0 5.000000
[2,]         0     0 1.414214
[3,]         0     0 1.414214
[4,]         0     0 1.414214
[5,]         0     0 1.414214
[6,]         0     0 1.414214

diag2$diagram

     dimension    Birth    Death
[1,]         0 0.000000 5.000000
[2,]         0 0.000000 1.414214
[3,]         0 0.000000 1.414214
[4,]         0 0.000000 1.414214
[5,]         0 0.000000 1.414214
[6,]         0 0.000000 1.414214
[7,]         2 1.414214 2.000000

When using the distance matrix as input, we see that we are unable to find the two-dimensional feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions