defuzzification

Function defuzzification 

Source
pub fn defuzzification<KV>(
    agg_memberships: &HashMap<String, Vec<Float>>,
    vars: &HashMap<KV, Variable>,
) -> Result<HashMap<String, Float>>
where KV: Eq + Hash + Borrow<str>,
Expand description

Defuzzify aggregated membership samples using the centroid-of-area method.

For each entry in agg_memberships, the function reconstructs a uniform x-grid from the variable’s domain and the vector length, then computes the centroid Σ x[i]·μ[i] / Σ μ[i].

Type parameters and bounds:

  • KV: key type for the variables map; must borrow as str.

Returns a map from output variable name to its crisp centroid value.

Errors

  • FuzzyError::BadArity if a membership vector has fewer than 2 samples.
  • FuzzyError::NotFound if a required output variable is missing from vars.