Skip to content

[AUD-025][Medium] Return EM likelihood matching returned parameters #321

Description

@gabrielsantosphilips

Audit finding

  • ID: AUD-025
  • Status: Verified defect
  • Severity: Medium
  • Confidence: High
  • Audited revision: 2f479320d805a1f9f35ebe4afaaeeded48913a94

Problem

On iteration exhaustion, ExpectationMaximization::Run() evaluates likelihood for currentParams, applies one final M-step, then returns the updated parameters with the old likelihood. A one-iteration call reports M(theta0) together with L(theta0).

Source:

EmParameters currentParams = initialParameters;
float prevLogLikelihood = std::numeric_limits<float>::lowest();
float logLikelihood = std::numeric_limits<float>::lowest();
std::size_t iter = 0;
bool converged = false;
while (iter < maxIterations)
{
const auto smootherOutput = smoother_.Smooth(
{ currentParams.F, currentParams.H, currentParams.Q, currentParams.R },
observations, numSteps,
currentParams.initialState, currentParams.initialCovariance);
logLikelihood = smootherOutput.logLikelihood;
++iter;
if (math::Abs(logLikelihood - prevLogLikelihood) < convergenceTolerance)
{
converged = true;
break;
}
prevLogLikelihood = logLikelihood;
currentParams = MStep(smootherOutput, observations, numSteps);
}
return EmResult{ currentParams, iter, logLikelihood, converged };
}

Acceptance criteria

  • Returned likelihood is evaluated for the returned parameter set.
  • Iteration count and convergence flag describe the same E/M sequence.
  • Add a one-iteration parameter/likelihood consistency test.
  • Add monotonic-likelihood checks with an independent reference sequence.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions