scalib.modeling.Lda#

class scalib.modeling.Lda(acc, p)[source]#

See LdaAcc.

Estimates the PDF parameters that is the projection matrix \(\mathbf{W}\), the means \(\mathbf{\mu}_x\) and the covariance \(\mathbf{\Sigma}\).

Parameters:
  • p (int) – Number of dimensions to keep after dimensionality reduction for each variable.

  • acc (LdaAcc) – Fitted LdaAcc instance.

Methods

predict_log2_proba_class(traces, x)

Computes the log2 probability for the given class for the traces,

predict_proba(traces)

Computes the probability for each of the classes for the traces,

project(traces)

Project the traces in the sub-linear space.

select_vars(vars)

Make a new Lda with only a subset of the variables (in the order given by the list).

predict_proba(traces)[source]#
Computes the probability for each of the classes for the traces,

for all variables.

Parameters:

traces (array_like, int16) – Array that contains the traces. The array must be of dimension (n,ns).

Returns:

Probability distributions. Shape (nv, n, nc).

Return type:

list of array_like, f64

predict_log2_proba_class(traces, x)[source]#
Computes the log2 probability for the given class for the traces,

for all variables.

Parameters:
  • traces (array_like, int16) – Array that contains the traces. The array must be of dimension (n,ns).

  • x (array_like, uint16) – Labels for each trace. Must be of shape (n, nv) and must be uint16.

Returns:

Log2 probabilities. Shape (nv, n).

Return type:

list of array_like, f64

project(traces)[source]#

Project the traces in the sub-linear space.

Parameters:

traces (numpy.typing.NDArray.numpy.int16) – Array that contains the traces. The array must be of dimension (n,ns).

Returns:

Projected traces. List of nv array of shape (n, self.p)

Return type:

array_like, f64

select_vars(vars)[source]#

Make a new Lda with only a subset of the variables (in the order given by the list).

Parameters:
  • traces – List of selected variables.

  • vars (list[int]) –

Returns:

A new Lda.

Return type:

Lda