scalarProduct function

Calculate the scalar product for functional data objects

Calculate the scalar product for functional data objects

This function calculates the scalar product between two objects of the class funData, irregFunData and multiFunData. For univariate functions f,gf,g on a domain TT, the scalar product is defined as [REMOVE_ME]Tf(t)g(t)dtTf(t)g(t)dt[REMOVEME2] \int_\mathcal{T} f(t) g(t) \mathrm{d}t\int_T f(t) g(t) dt [REMOVE_ME_2] and for multivariate functions f,gf,g on domains T1,,TpT_1,\ldots,T_p, it is defined as [REMOVE_ME] \sum_{j = 1}^p\int_{\mathcal{T}_j} f^{(j)}(t) g^{(j)}(t) \mathrm{d}t.\sum_{j = 1}^p\int_T_j f^{(j)}(t) g^{(j)}(t) dt. [REMOVE_ME_2] As seen in the formula, the objects must be defined on the same domain. The scalar product is calculated pairwise for all observations, thus the objects must also have the same number of observations or one object may have only one observation (for which the scalar product is calculated with all observations of the other object)). Objects of the classes funData and irregFunData

can be combined, see integrate for details.

scalarProduct(object1, object2, ...)

Arguments

  • object1, object2: Two objects of classfunData, irregFunData or multiFunData, for that the scalar product is to be calculated.
  • ...: Additional parameters passed to integrate. For multiFunData objects, one can also pass a weight argument. See Details.

Returns

A vector of length nObs(object1) (or nObs(object2), if object1 has only one observation), containing the pairwise scalar product for each observation.

Description

This function calculates the scalar product between two objects of the class funData, irregFunData and multiFunData. For univariate functions f,gf,g on a domain TT, the scalar product is defined as

Tf(t)g(t)dtTf(t)g(t)dt \int_\mathcal{T} f(t) g(t) \mathrm{d}t\int_T f(t) g(t) dt

and for multivariate functions f,gf,g on domains T1,,TpT_1,\ldots,T_p, it is defined as

\sum_{j = 1}^p\int_{\mathcal{T}_j} f^{(j)}(t) g^{(j)}(t) \mathrm{d}t.\sum_{j = 1}^p\int_T_j f^{(j)}(t) g^{(j)}(t) dt.

As seen in the formula, the objects must be defined on the same domain. The scalar product is calculated pairwise for all observations, thus the objects must also have the same number of observations or one object may have only one observation (for which the scalar product is calculated with all observations of the other object)). Objects of the classes funData and irregFunData

can be combined, see integrate for details.

Details

For multiFunData one can pass an optional vector weight for calculating a weighted scalar product. This vector must have the same number of elements as the multiFunData objects and have to be non-negative with at least one weight that is different from 0. Defaults to 1 for each element. See also norm.

Examples

# create two funData objectw with 5 observations on [0,1] f <- simFunData(N = 5, M = 7, eValType = "linear", eFunType = "Fourier", argvals = seq(0,1,0.01))$simData g <- simFunData(N = 5, M = 4, eValType = "linear", eFunType = "Poly", argvals = seq(0,1,0.01))$simData # calculate the scalar product scalarProduct(f,g) # the scalar product of an object with itself equals the squared norm all.equal(scalarProduct(f,f), norm(f, squared = TRUE)) # This works of course also for multiFunData objects... m <- multiFunData(f,g) all.equal(scalarProduct(m,m), norm(m, squared = TRUE)) # ...and for irregFunData objects i <- as.irregFunData(sparsify(f, minObs = 5, maxObs = 10)) all.equal(scalarProduct(i,i), norm(i, squared = TRUE)) # Scalar product between funData and irregFunData objects scalarProduct(i,f) # Weighted scalar product for multiFunData objects scalarProduct(m,m, weight = c(1,2))

See Also

integrate, norm,