Closed m5signorini closed 1 year ago
Modifying the cov
method affects tests that were assuming an FDataGrid
as the result from calling it.
I believe this can be solved converting the result from cov
using to_grid
in such cases.
Patch coverage: 91.12
% and project coverage change: +0.05
:tada:
Comparison is base (
fbe63ce
) 85.77% compared to head (4c411e4
) 85.83%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Latest commits were done in order to overload the cov
method, adding the possibility to pass points of evaluation.
I believe that due to the nature of @overload
, only the last method is used as implementation and taking into account the overloaded methods in the parent class is tricky, thus I needed to include the same signatures in both FDataBasis
and FDataGrid
.
I don't know if there is a better way to overload the method other than expecting optionally None
values and checking at runtime.
Latest commits aim to eliminate the use of cov()
and use instead cov(s,t)
for evaluating the covariance function. This changes are applied only where the data matrix is needed. The only other instances of calls cov()
appear in CovarianceEstimator
and for now it is expected to use a FData
object.
@pcuestas You needed this PR, so you can now start.
Replacing the
cov
method ofFDataBasis
to use tensor basis instead of a numerical approximation. This method should calculate the unbiased covariance function, which, given a list of univariate data $\{xn\}{n=1}^N$, it is defined as$$K(t,s) =\frac{1}{N-1} \sum_{n=1}^N (x_n(t) - \bar{x}(t))(x_n(s) - \bar{x}(s)).$$
If the functions $xn$ are expressed in a basis $\{\phi\}^J{j=1}$ such that $x_n(t) = \sum \alpha_j^{(n)}\phi_j(t)$ then
$$ K (t,s) = \frac{1}{N-1} \sum{n=1}^N \left( \sum{j=1}^J(\alpha_j^{(n)} - \bar{\alpha}_j)\phij(t)\right) \left( \sum{j=1}^J(\alpha_j^{(n)} - \bar{\alpha}_j)\phi_j(s)\right), $$
which it translates into calculating the covariance matrix of the coefficients $\alpha$ centered. Thus,
$$ K(t,s) = \Phi(t)^T C \Phi(s), $$
where $\Phi$ is the basis functions as a column vector and $C$ is the unbiased sample covariance matrix of the coefficients. Thus $K$ has the matrix $C$ as coefficients in the tensor basis $\{\phi_1(t)\phi_1(s),\quad \phi_1(t)\phi_2(s), \quad \cdots, \quad \phi_J(t)\phi_J(s)\}$