Skip to main content

weighted_average_position

Function weighted_average_position 

Source
pub fn weighted_average_position(rows: &[PositionRow]) -> Result<f64, SerpError>
Expand description

Impression-weighted average position across many rows.

This is the only correct way to combine per-query or per-page average positions: a plain mean of the position column lets a row with three impressions outvote a row with thirty thousand.

ยงErrors

Returns SerpError::EmptyInput for an empty slice, SerpError::InvalidPosition for a non-finite or sub-1.0 position, and SerpError::NoImpressions when every row has zero impressions.