Description Usage Arguments Details Value See Also Examples

View source: R/funDataMethods.R

This function calculates the scalar product between two objects of the class
`funData`

, `irregFunData`

and
`multiFunData`

. For univariate functions *f,g* on a
domain *\calT*, the scalar product is defined as

*\int_\calT f(t) g(t) dt*

and
for multivariate functions *f,g* on domains *\calT_1,…,\calT_p*, it is defined as

*∑_{j = 1}^p
\int_\calT_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.

1 | ```
scalarProduct(object1, object2, ...)
``` |

`object1, object2` |
Two objects of class |

`...` |
Additional parameters passed to |

For `multiFunData`

one cann pass 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`

.

A vector of length `nObs(object1)`

(or `nObs(object2)`

, if
`object1`

has only one observation), containing the pairwise scalar
product for each observation.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ```
# 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))
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.