Skip to content

num::clip_and_normalize_nonnegative

Defined in header <stats/probability.hpp>

real clip_and_normalize_nonnegative(view<real> values);

Set negative entries to zero and scale to sum 1: \(p_i \leftarrow \max(p_i, 0) / \sum_j \max(p_j, 0)\). Returns the mass before normalizing.