cleverly.bases.Cosine#

class cleverly.bases.Cosine(columns: Sequence[str], size: int = 1, domains: Mapping[str, tuple[float, float]] | tuple[tuple[str, tuple[float, float]], ...] = (), intercept: bool = True)[source]#

Cosines of each modifier on its declared domain.

Column \(j = 1, \ldots, \text{size}\) of modifier \(v\) on the domain \([l, h]\) is \(\sqrt 2 \cos(j \pi (v - l)/(h - l))\), orthonormal under the uniform law on the domain. The domain comes from domains or from the declared Modifiers, never from the rows.

Parameters:
columnssequence of str

The continuous modifiers.

sizeint

The number of cosines per modifier.

domainsmapping of str to (float, float), optional

Domains carried by the basis itself, which take precedence over the schema’s.

interceptbool

Whether to prepend the intercept column.

Methods#

Cosine.domain_of(column: str) → tuple[float, float] | None[source]#

The domain this basis carries for column, or None.

Parameters:
columnstr

A modifier column.

Returns:
tuple of float or None

(low, high), or None.

Cosine.truncate(k: int) → Cosine[source]#

The first k cosines of each modifier.

Parameters:
kint

A size between one and max_size.

Returns:
Cosine

The truncated basis, whose span lies inside this one’s.

Attributes#

Cosine.domains: Mapping[str, tuple[float, float]] | tuple[tuple[str, tuple[float, float]], ...] = ()#
Cosine.intercept: bool = True#
Cosine.max_size#

The declared size.

Cosine.size: int = 1#
Cosine.columns: Sequence[str]#

The modifier columns the basis reads: a field or a property of each subclass.