Skip to content

Add std to fitters.py #73

Description

@LeonidElkin

Add characteristic std

Naming convention: "std".

std denotes the standard deviation of a random variable:
std(X) = sqrt(Var(X)).

1. Relation to variance

Standard deviation is defined as the square root of variance:

  • std(X) = sqrt(var(X))
  • var(X) = central_moment(order=2)

No independent statistical computation logic should be implemented inside std.

All mathematical logic for obtaining dispersion-related quantities must live in:

  • central_moment(order=2) (primary definition),
  • and/or var (as its thin wrapper).

std must be implemented strictly as a thin wrapper over var, applying an elementwise square root.

There must be no alternative computational paths that bypass var.

2. Integration into the characteristic graph

  • Register std as a node in the global characteristic graph.
  • Add a single edge:
    • var -> std

The planner must obtain std exclusively via var.

No direct edges from:

  • central_moment,
  • raw_moment,
  • pdf,
  • pmf,
  • or any other characteristic

should exist.

3. Implementation requirements

  • The implementation must support NumPy array semantics.
  • The square root must be applied elementwise.
  • Behavior for negative numerical noise (e.g., tiny negative values due to floating-point errors) must be defined:
    • Either clamp small negative values to zero within tolerance,
    • Or raise a well-defined error (decision must be consistent with var policy).

The behavior must be explicitly tested.

4. Tests

Add tests that verify:

  • std equals sqrt(var) for analytical distributions.
  • For at least one distribution:
    • std matches the analytical standard deviation (within tolerance).
    • std equals sqrt(central_moment(order=2)) via the graph.
  • Array semantics:
    • Scalar input,
    • Vector input,
    • Broadcasting behavior (if applicable).

Metadata

Metadata

Assignees

Labels

Fields

No fields configured for Feature.

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions