jdtuck / fdasrvf_R

Functional Data Analysis using Square-Root Slope Framework
11 stars 15 forks source link

Documentation clarification #36

Closed astamm closed 9 months ago

astamm commented 9 months ago

Hi @jdtuck. I am trying to use elastic distance with rotational invariance to compute both distances and karcher means for 3-dimensional curves.

Digging into the code, I find two functions find_rotation_seed_unqiue() and find_rotation_seed_coord() that seem to be the ones doing the actual optimisation (rotation, scale and alignment). I wonder what is the difference between the two? From the code, it seems that the former requires the SRVFs as input while the latter requires the original functions and also the former has the possibility to add a penalty term. Can you please expand?

Also, I have the impression that calc_shape_dist() and curve_pair_align() should behind the scene perform the same optimisations, the former returning distances while the latter returning the aligned (possibly rotated and scaled) second curve. But when I use both functions on a curve and the same curve to which I applied a constant rotation, curve_pair_align() correctly overlap the two curves if rotation==TRUE while, with calc_shape_dist(), I have to ask both rotation==TRUE and scale==TRUE to make the curves overlap.

Lastly, I found that both curve_karcher_mean() and curve_srvf_align() actually compute the Karcher mean. The latter calls the former as initialisation step from what I understand. But curve_karcher_mean() seems buggy. The example that comes with the documentation produces a mean curve that does not seem to be in the middle of the sample for instance. As for curve_srvf_align(), there is the line out = find_best_rotation(mu, q1n) which is performed regardless of optional argument rotated which seems off.

Can you clarify please as I am struggling to use and understand the differences between all these functions. I flag @araiari as well if she wants to jump into the conversation.

Thanks for your time.

jdtuck commented 9 months ago

First note, please use latest version off github before filing any issues.

find_rotation_seed_unqiue() and find_rotation_seed_coord() are similar as you have described and difference are using curves directly or the srvf. There are times for each.

calc_shape_dist() and curve_pair_align() should perform the same operations. There might be a scaling bug in one of them that we need to track down. There was and adjustment in the package to change the way we use scale.

That is correct curve_srvf_align() aligns curves to the mean so it first computes the mean. We have done a lot of bugfixing on curve_karcher_mean() this past week due to the changes in scale so please check with latest off of the master branch.

Also these questions are better over e-mail or other forms than as an issue. Please use the issue for actual issues on a single function.