Norms#
Norms and likelihoods for comparing two values.
- class LNorm(p: int)[source]#
Bases:
NormClass for L-norms.
- __init__(p: int)[source]#
Initialize the class with the provided parameters.
- Parameters:
p (
int) – The order of the norm. seenumpy.linalg.norm()for details.
-
p:
int# The order of the norm.
- class L2Norm[source]#
Bases:
LNormClass for L2-norm (Euclidean distance).
- compute(a: float | ndarray, b: float | ndarray)#
Compare two values.
- Parameters:
a (
float|ndarray) – A value.b (
float|ndarray) – Another value.
- Return type:
float|int- Returns:
A numerical value representing the difference between the two values.
-
p:
int# The order of the norm.
- class L1Norm[source]#
Bases:
LNormClass for L1-norm (Manhattan distance).
- compute(a: float | ndarray, b: float | ndarray)#
Compare two values.
- Parameters:
a (
float|ndarray) – A value.b (
float|ndarray) – Another value.
- Return type:
float|int- Returns:
A numerical value representing the difference between the two values.
-
p:
int# The order of the norm.
- class LInfNorm[source]#
Bases:
LNormClass for L-infinity norm (Chebyshev distance).
- compute(a: float | ndarray, b: float | ndarray)#
Compare two values.
- Parameters:
a (
float|ndarray) – A value.b (
float|ndarray) – Another value.
- Return type:
float|int- Returns:
A numerical value representing the difference between the two values.
-
p:
int# The order of the norm.
- class Likelihood[source]#
Bases:
Norm,ABCAbstract class for likelihoods.
- compute(a: Any, b: Any)#
Compare two values.
- Parameters:
a (
Any) – A value.b (
Any) – Another value.
- Return type:
float|int- Returns:
A numerical value representing the difference between the two values.
- class PoissonLikelihood[source]#
Bases:
LikelihoodClass for Poisson likelihoods. Site frequency spectra are often assumed to be independent Poisson random variables.
- compute(observed: Iterable, modelled: Iterable)[source]#
Return additive inverse of Poisson log-likelihood assuming independent entries. Note that the returned likelihood is a positive value which ought to be minimized.
- Parameters:
observed (
Iterable) – Observed values.modelled (
Iterable) – Modelled values.
- Return type:
float|int- Returns:
A numerical value representing the difference between the two values.