Skip to content

Helper function normal_known_variance_inputs missing var parameter #287

@williambdean

Description

@williambdean

Summary

The normal_known_variance_inputs helper function doesn't include the required var parameter that the normal_known_variance model expects.

Current Behavior

from conjugate.helpers import normal_known_variance_inputs

data = [2.3, 1.9, 2.7, 2.1, 2.5]
inputs = normal_known_variance_inputs(data)
# Returns: {'x_total': 11.5, 'n': 5}

Expected Behavior

The helper should optionally accept and return the var parameter:

inputs = normal_known_variance_inputs(data, var=0.5)
# Returns: {'x_total': 11.5, 'n': 5, 'var': 0.5}

Problem

The model signature requires var:

def normal_known_variance(*, x_total, n, var, prior):

Currently users must do:

posterior = normal_known_variance(**inputs, var=0.5, prior=prior)

This breaks the pattern shown in documentation where helpers provide all required inputs.

Suggested Fix

def normal_known_variance_inputs(x, *, var=None, sum_fn=None, len_fn=None):
    result = {
        "x_total": sum_fn(x),
        "n": len_fn(x),
    }
    if var is not None:
        result["var"] = var
    return result

Also Affects

  • normal_known_precision_inputs - missing precision parameter

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmodelsHas to do with the models

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions