Table of Contents

Interface ILikelihoodCostFunction

Namespace
SignalSharp.CostFunctions.Cost
Assembly
SignalSharp.dll

Optional interface for PELT cost functions that can provide likelihood-based metrics and parameter counts necessary for information criteria (BIC, AIC, AICc).

public interface ILikelihoodCostFunction : IPELTCostFunction
Inherited Members

Properties

SupportsInformationCriteria

Indicates if the cost function provides valid likelihood metrics and parameter counts suitable for use with information criteria like BIC and AIC.

If true, the cost function must correctly implement ComputeLikelihoodMetric(int, int) and GetSegmentParameterCount(int).

bool SupportsInformationCriteria { get; }

Property Value

bool

Methods

ComputeLikelihoodMetric(int, int)

Computes a metric related to the negative log-likelihood for a given segment.

This metric should be proportional to -2 * logLikelihood(segment | parameters_MLE), potentially omitting constant terms that depend only on the data itself (like n*log(2*pi) or Sum(log(k!))) as these usually cancel out in model comparisons using information criteria.

double ComputeLikelihoodMetric(int start, int end)

Parameters

start int

The start index of the segment (inclusive).

end int

The end index of the segment (exclusive).

Returns

double

The likelihood-related metric for the segment. Should return double.PositiveInfinity if the metric cannot be computed (e.g., due to invalid segment length, zero variance).

Exceptions

SegmentLengthException

Thrown if segment length is invalid for the underlying model.

ArgumentOutOfRangeException

Thrown if start or end indices are out of bounds.

UninitializedDataException

Thrown if Fit(double[,]) or Fit(double[]) has not been called.

CostFunctionException

Thrown if an unexpected error occurs during metric calculation.

GetSegmentParameterCount(int)

Gets the number of effective parameters estimated for a single segment of the given length by the underlying statistical model associated with the cost function.

This count should include parameters like mean, variance, rate, probability, AR coefficients, etc., depending on the cost function. It does not include the changepoint locations themselves, as those are typically accounted for separately in the penalty term of information criteria.

int GetSegmentParameterCount(int segmentLength)

Parameters

segmentLength int

The length of the segment. This might be relevant for some models (e.g., if parameter count depends on length), but often it's constant.

Returns

int

The number of parameters estimated within the segment model.

Exceptions

UninitializedDataException

Thrown if Fit(double[,]) or Fit(double[]) has not been called.