Skip to content

Commit

Permalink
Merge pull request #542 from ego-thales/develop
Browse files Browse the repository at this point in the history
SRSF formula doc fix
  • Loading branch information
vnmabus committed Jun 22, 2023
2 parents b7e0023 + 2aee87b commit 0154d69
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions skfda/misc/metrics/_fisher_rao.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class FisherRaoDistance():
.. math::
d_{FR}(f_i, f_j) = \| q_i - q_j \|_2 =
\left ( \int_0^1 sgn(\dot{f_i}(t))\sqrt{|\dot{f_i}(t)|} -
sgn(\dot{f_j}(t))\sqrt{|\dot{f_j}(t)|} dt \right )^{\frac{1}{2}}
\left ( \int_0^1 sgn(f_i'(t))\sqrt{|f_i'(t)|} -
sgn(f_j'(t))\sqrt{|f_j'(t)|} dt \right )^{\frac{1}{2}}
If the observations are distributions of random variables the distance will
match with the usual Fisher-Rao distance in non-parametric form for
Expand Down Expand Up @@ -164,7 +164,7 @@ def fisher_rao_amplitude_distance(
given by
.. math::
\mathcal{R}(\gamma) = \|\sqrt{\dot{\gamma}}- 1 \|_{\mathbb{L}^2}^2
\mathcal{R}(\gamma) = \|\sqrt{\gamma'}- 1 \|_{\mathbb{L}^2}^2
See the :footcite:`srivastava+klassen_2016_functionala` for a
detailed explanation.
Expand Down Expand Up @@ -260,7 +260,7 @@ def fisher_rao_phase_distance(
.. math::
d_{P}(f_i, f_j) = d_{FR}(\gamma_{ij}, \gamma_{id}) =
arcos \left ( \int_0^1 \sqrt {\dot \gamma_{ij}(t)} dt \right )
arcos \left ( \int_0^1 \sqrt {\gamma_{ij}'(t)} dt \right )
where :math:`\gamma_{id}` is the identity warping.
Expand Down Expand Up @@ -346,7 +346,7 @@ def _fisher_rao_warping_distance(
.. math::
d_{\Gamma}(\gamma_i, \gamma_j) = cos^{-1} \left ( \int_0^1
\sqrt{\dot \gamma_i(t)\dot \gamma_j(t)}dt \right )
\sqrt{\gamma_i'(t)\gamma_j'(t)}dt \right )
See :footcite:`srivastava+klassen_2016_functionala` for a detailed
explanation.
Expand Down
6 changes: 3 additions & 3 deletions skfda/misc/operators/_srvf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SRSF(
function, the SRSF transform is defined as
.. math::
SRSF(f(t)) = sgn(f(t)) \sqrt{|\dot f(t)|} = q(t)
SRSF(f(t)) = sgn(f'(t)) \sqrt{|f'(t)|} = q(t)
This representation it is used to compute the extended non-parametric
Fisher-Rao distance between functions, wich under the SRSF representation
Expand Down Expand Up @@ -137,7 +137,7 @@ def transform(self, X: FDataGrid, y: object = None) -> FDataGrid:
.. math::
SRSF(f(t)) = sgn(f(t)) \sqrt{\dot f(t)|} = q(t)
SRSF(f(t)) = sgn(f'(t)) \sqrt{f'(t)|} = q(t)
Args:
X: Functions to be transformed.
Expand Down Expand Up @@ -166,7 +166,7 @@ def transform(self, X: FDataGrid, y: object = None) -> FDataGrid:
# Evaluation with the corresponding interpolation
data_matrix = g(output_points)[..., 0]

# SRSF(f) = sign(f) * sqrt|Df| (avoiding multiple allocation)
# SRSF(f) = sign(f') * sqrt|f'| (avoiding multiple allocation)
sign_g = np.sign(data_matrix)
data_matrix = np.abs(data_matrix, out=data_matrix)
data_matrix = np.sqrt(data_matrix, out=data_matrix)
Expand Down
4 changes: 2 additions & 2 deletions skfda/preprocessing/registration/_fisher_rao.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ class FisherRaoElasticRegistration(
.. math::
d_{\lambda}^2(f \circ \gamma, g) = \| SRSF(f \circ \gamma)
\sqrt{\dot{\gamma}} - SRSF(g)\|_{\mathbb{L}^2}^2 + \lambda
\sqrt{\gamma'} - SRSF(g)\|_{\mathbb{L}^2}^2 + \lambda
\mathcal{R}(\gamma)
In the implementation it is used as penalty term
.. math::
\mathcal{R}(\gamma) = \|\sqrt{\dot{\gamma}}- 1 \|_{\mathbb{L}^2}^2
\mathcal{R}(\gamma) = \|\sqrt{\gamma'}- 1 \|_{\mathbb{L}^2}^2
Wich restrict the amount of elasticity employed in the alignment.
Expand Down
10 changes: 5 additions & 5 deletions skfda/preprocessing/registration/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,12 @@ class SobolevLeastSquares(RegistrationScorer[FData, FData]):
[S11-5-2-3]_:
.. math::
sls=1 - \frac{\sum_{i=1}^{N} \int\left(\dot{\tilde{f}}_{i}(t)-
\frac{1}{N} \sum_{j=1}^{N} \dot{\tilde{f}}_{j}\right)^{2} dt}
{\sum_{i=1}^{N} \int\left(\dot{f}_{i}(t)-\frac{1}{N} \sum_{j=1}^{N}
\dot{f}_{j}\right)^{2} dt}
sls=1 - \frac{\sum_{i=1}^{N} \int\left(\tilde{f}_i'(t)-
\frac{1}{N} \sum_{j=1}^{N} \tilde{f}_j'\right)^{2} dt}
{\sum_{i=1}^{N} \int\left(f_i'(t)-\frac{1}{N} \sum_{j=1}^{N}
f_j'\right)^{2} dt}
where :math:`\dot{f}_i` and :math:`\dot{\tilde{f}}_i` are the derivatives
where :math:`f_i'` and :math:`\tilde{f}_i'` are the derivatives
of the original and the registered data respectively.
This criterion measures the total cross-sectional variance of the
Expand Down

0 comments on commit 0154d69

Please sign in to comment.