Exemplo n.º 1
0
plot_diagrams(PH_sub['dgms'])
plt.show()

# %% codecell
eta, birth, death = pipeline.prominent_cocycle(PH_sub['cocycles'][1],
    PH_sub['dgms'][1])

# %% codecell
print(eta)
print('Birth: %2.4f' %birth)
print('Death: %2.4f' %death)

# %% codecell
# Get a partition of unity.
print('Computing partition of unity.')
part_func = pipeline.partition_unity(D, 0.26, idx, bump_type='quadratic')
print('Finding projective coordinates.')
proj_coords = pipeline.proj_coordinates(part_func, eta)
print('Computing distance matrix of projective coordinates.')
D_pc = geometry.RPn_geo_distance_matrix(proj_coords)
print('Estimating geodesic distance matrix.')
D_geo = pipeline.geo_distance_matrix(D_pc, k=12)

# %% codecell
# Compute PH of landmarks of high-dimensional data.
print('Computing persistence of projective coordinates.')
PH_pc2 = ripser(D_geo[idx,:][:,idx], distance_matrix=True, maxdim=1, coeff=2)
plot_diagrams(PH_pc2['dgms'])
plt.title('Persistence of Projective Coordinates ($F_2$)')
plt.show()
PH_pc3 = ripser(D_geo[idx,:][:,idx], distance_matrix=True, maxdim=1, coeff=3)
Exemplo n.º 2
0
# Perform the full projective coordinates pipeline.
# Get the main H^2 cocycle.
reload(pipeline)
cocycles = PH['cocycles'][2]
dgms = PH['dgms'][2]
eta, birth, death = pipeline.prominent_cocycle(cocycles, dgms)
print(birth, death)
print(eta.shape)
# Thresholding is now important! My VR computation doesn't like extra cocycles.

# %% codecell
# Make a big for loop and try a bunch of parameters.
eta = pipeline.threshold_cocycle(eta, D_sub, birth + .01)
beta = pipeline.integer_lift(eta, p)
theta, nu = pipeline.harmonic_cocycle(beta, D_sub, p, birth + .01)
part_func = pipeline.partition_unity(D, death - .01, sub_ind)
CPn_coords = pipeline.CPn_coordinates(part_func, theta, nu)
D_pc = geometry.CPn_geo_distance_matrix(CPn_coords)
PH_pc = ripser(D_pc[sub_ind, :][:, sub_ind], distance_matrix=True, maxdim=2)
plot_diagrams(PH_pc['dgms'])
plt.title('Persistence with radius parameter %1.3f' % (death - .01))
plt.show()

# %% codecell
CPn_cplx = geometry.complexify(CPn_coords)
stuff = ppca.ppca(CPn_cplx.T, 1, verbose=True)
X_ppca = geometry.realify(stuff['X'].T)
print(X_ppca.shape)

#%%
D_pca = geometry.CPn_geo_distance_matrix(X_ppca)
# plt.savefig(pathname+'klein_bottle_landmarks_F3.png', dpi=300)
plt.show()

# %% codecell
# Get a prominent cocycle in dimension one.
print('Computing projective coordinates in dimension %d.' % len(sub_ind))
cocycles = PH_sub['cocycles'][1]
diagram = PH_sub['dgms'][1]
eta, birth, death = pipeline.prominent_cocycle(cocycles, diagram, order=2)
print(birth, death)

# %% codecell
# Get a partition of unity.
eta = pipeline.threshold_cocycle(eta, D_sub, birth + .01)
part_func = pipeline.partition_unity(D,
                                     death - 0.01,
                                     sub_ind,
                                     bump_type='quadratic')
proj_coords = pipeline.proj_coordinates(part_func, eta)
D_pc = geometry.RPn_geo_distance_matrix(proj_coords)
D_geo = pipeline.geo_distance_matrix(D_pc, k=8)

# %% codecell
# Compute PH of landmarks of high-dimensional data.
PH_pc = ripser(D_geo[sub_ind, :][:, sub_ind],
               distance_matrix=True,
               maxdim=2,
               coeff=2)
plot_diagrams(PH_pc['dgms'])
plt.show()

# %% codecell