Skip to content

mean(skipmissing(x)) is imprecise #56456

@tiemvanderdeure

Description

@tiemvanderdeure

The generic fallback for mean can give wrong results in some cases. Maybe it would be a good idea to add a specialized implementation when it is called on a SkipMissing, as there is for sum. The easiest way to do this would be to pass a function that computes both sum and count to mapreduce.

A = rand(Float32, 1_000_000) .+ 1f6
mean(skipmissing(A))  mean(A) # false
mean(A)  (sum(skipmissing(A)) / length(A)) # true

Related: #30421

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateIndicates similar issues or pull requestsfoldsum, maximum, reduce, foldl, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions