jdtuck / fdasrvf_R

Functional Data Analysis using Square-Root Slope Framework
10 stars 13 forks source link

Distance between a curve and itself is not zero! #9

Closed pankajmath closed 5 years ago

pankajmath commented 5 years ago

The version on CRAN has the issue of non-zero distance (cal_shape_dist) between a curve and itself. For example, calc_shape_dist(beta[,,1,1],beta[,,1,1]) = 0.000133296. Could you please look into this issue?

Regards, Pankaj

jdtuck commented 5 years ago

So this has to do with numerical calculation of the procrustes rigid alignment, we don't quite get a identity matrix back due to floating point error. The only fix is to check if they are exact and report back 0 distance. I have debated with myself if I want to do this. That results is close to 0 given the rotation matrix that is not quite identity.

pankajmath commented 5 years ago

Thank you very much for your response. It seems that very small distances (like 10^-2) should not be taken seriously. I was trying to compare the shape distances between different curves and the maximum distance I get is 0.021 and the minimum distance is 0.0079 (which is the distance of a curve from itself). I don't know if I could conclude anything from these distances. As you suggested, I could make the distance of a curve from itself zero by checking if they are same to begin with. However, there are cases, where they are different and the distance between them is 0.009 or so. If you have any thoughts on this, please share them.

Regards, Pankaj

jdtuck commented 5 years ago

Do you have some example data you can share?

/vr

Derek

On September 20, 2018 at 9:23:27 AM MDT, Pankaj Singh notifications@github.com wrote:

Thank you very much for your response. It seems that very small distances (like 10^-2) should not be taken seriously. I was trying to compare the shape distances between different curves and the maximum distance I get is 0.021 and the minimum distance is 0.0079 (which is the distance of a curve from itself). I don't know if I could conclude anything from these distances. As you suggested, I could make the distance of a curve from itself zero by checking if they are same to begin with. However, there are cases, where they are different and the distance between them is 0.009 or so. If you have any thoughts on this, please share them.

Regards, Pankaj

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jdtuck/fdasrvf_R/issues/9#issuecomment-423224170, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACN8Ux3DjG4eC0qGXipXNOdMTcWNdPZFks5uc7LpgaJpZM4Ws0h8.

jdtuck commented 5 years ago

Also, you can make sense of those distances, the magnitude is relative. Without looking at your data I can't really offer any more solutions. Something tells me they are very similar, if they are not, there is a larger problem at play

pankajmath commented 5 years ago

Yes, please see the attached zipped directory. The RData file an_example.RData has three variables (ar-[ 2x99x19 array], curves and dist_mat). From the array ar, we randomly select some curves and find their Karcher mean curve. We find that there are some issues with the calculation of the Karcher mean too. Whenever the calculation finishes in just one iteration vs more than one iteration. One should be able to see very different curves (some centered and some non-centered, it seems). Finally, we calculate the pairwise shape distances between these mean curves. The attached code regenerates everything.

to_share_with_Derek.zip

Thank you for help and looking into the issues.

Regards, Pankaj

jdtuck commented 5 years ago

These open curves are very similar and computing the distance between the means will give distances that are very similar. Why do you want to do this, seems more natural to find the distance matrix for all the curves in the set. Moreover, with the curves being so similar and open, are they actually curves or should we treat them as 1-D functions?

jdtuck commented 5 years ago

I also made a small change, you might want to install from github directly

jdtuck commented 5 years ago

rplot

here is the heatmap of the distance matrix, curves are very similar. But there is information there...

jdtuck commented 5 years ago

treating them as 1-D functions gives a different result, you can look at the time_warping function and elastic.distance. I am going to close this, please feel free to reach out to me if you have any questions. Curious on what you are trying to analyze with these curves.