Skip to content

anyone thought to ignore nulls, as an option #42

Description

@jcquarto

Often I have holes in my data, and I want to get some stats but ignore nulls.
example:
data = [1, 2, 3, 4, 5, nil] # => [1, 2, 3, 4, 5, nil]
stats = DescriptiveStatistics::Stats.new(data)
stats.mean # => 2.5

because the nil is treated like a zero. If instead this "data hole" is ignored, the mean should be 3.0, as in
stats = DescriptiveStatistics::Stats.new(data.compact)
stats.mean # => 3.0

Has there been any discussion of an optional parameter to ignore nulls? Perhaps something like:
stats = DescriptiveStatistics::State.new(data, ignore_nulls=true)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions