LinearDifferentialOperator#

class skfda.misc.operators.LinearDifferentialOperator(order_or_weights=None, *, order=None, weights=None, domain_range=None)[source]#

Defines the structure of a linear differential operator function system.

\[Lx(t) = b_0(t) x(t) + b_1(t) x'(t) + \dots + b_{n-1}(t) D^{n-1}(x(t)) + b_n(t) D^n(x(t))\]

Can only be applied to functional data, as multivariate data has no derivatives.

You have to provide either order or weights. If both are provided, it will raise an error. If a positional argument is supplied it will be considered the order if it is an integral type and the weights otherwise.

Parameters:
  • order (int | None) – the order of the operator. It’s the highest derivative order of the operator.

  • weights (WeightSequence | None) – A FDataBasis objects list of length order + 1 items.

  • domain_range (DomainRangeLike | None) – Definition of the interval where the weight functions are defined. If the functional weights are specified and this is not, takes the domain range from them. Otherwise, defaults to (0,1).

  • order_or_weights (Order | WeightSequence | None) –

Attributes:

weights (list) – A list of callables.

Examples

Create a linear differential operator that penalizes the second derivative (acceleration)

>>> from skfda.misc.operators import LinearDifferentialOperator
>>> from skfda.representation.basis import (FDataBasis,
...                                         MonomialBasis,
...                                         ConstantBasis)
>>>
>>> LinearDifferentialOperator(2)
LinearDifferentialOperator(
    weights=(0, 0, 1),
)

Create a linear differential operator that penalizes three times the second derivative (acceleration) and twice the first (velocity).

>>> LinearDifferentialOperator(weights=[0, 2, 3])
LinearDifferentialOperator(
    weights=(0, 2, 3),
)

Create a linear differential operator with non-constant weights.

>>> constant = ConstantBasis()
>>> monomial = MonomialBasis(domain_range=(0, 1), n_basis=3)
>>> fdlist = [FDataBasis(constant, [0.]),
...           FDataBasis(constant, [0.]),
...           FDataBasis(monomial, [1., 2., 3.])]
>>> LinearDifferentialOperator(weights=fdlist)
LinearDifferentialOperator(
weights=(FDataBasis(
        basis=ConstantBasis(domain_range=((0.0, 1.0),), n_basis=1),
        coefficients=[[ 0.]],
        ...),
    FDataBasis(
        basis=ConstantBasis(domain_range=((0.0, 1.0),), n_basis=1),
        coefficients=[[ 0.]],
        ...),
    FDataBasis(
        basis=MonomialBasis(domain_range=((0.0, 1.0),), n_basis=3),
        coefficients=[[ 1. 2. 3.]],
        ...)),
)

Methods

constant_weights()

Return constant weights.

constant_weights()[source]#

Return constant weights.

Return the scalar weights of the linear differential operator if they are constant basis. Otherwise, return None.

This function is mostly useful for basis which want to override the _penalty method in order to use an analytical expression for constant weights.

Return type:

NDArrayFloat | None