4.7.7 pde.tools.math module

Auxiliary mathematical functions.

SmoothData1D

Allows smoothing data in 1d using a Gaussian kernel of defined width.

OnlineStatistics

Class for using an online algorithm for calculating statistics.

class OnlineStatistics[source]

Bases: object

Class for using an online algorithm for calculating statistics.

add(value: float) → None[source]

Add a value to the accumulator.

Parameters:

value (float) – The value to add

property std: float

recorded standard deviation

Type:

float

to_dict() → dict[str, Any][source]

Return the information as a dictionary.

property var: float

recorded variance

Type:

float

class SmoothData1D(x, y, sigma: float | None = None)[source]

Bases: object

Allows smoothing data in 1d using a Gaussian kernel of defined width.

The data is given a pairs of x and y, the assumption being that there is an underlying relation y = f(x).

Initialize with data.

Parameters:
  • x – List of x values

  • y – List of y values

  • sigma (float) – The size of the smoothing window in units of x. If omitted, the average distance of x values multiplied by sigma_auto_scale is used.

property bounds: tuple[float, float]

Return minimal and maximal x values.

derivative(xs: ArrayLike) → NumericArray[source]

Return the derivative of the smoothed values for the positions xs

Note that this value

Parameters:

xs (list of ndarray) – the x-values

Returns:

The associated values of the derivative

Return type:

ndarray