Skip to content

Incorrect Histogram fit for arrays of equal Float64 values #616

@yurivish

Description

@yurivish
julia> using StatsBase

julia> fit(Histogram, [1 for _ in 1:1000])
Histogram{Int64,1,Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}}
edges:
  1.0:1.0:2.0
weights: [1000]
closed: left
isdensity: false

julia> fit(Histogram, [1.234 for _ in 1:1000])
Histogram{Int64,1,Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}}
edges:
  2.234:2.0:4.234
weights: [0]
closed: left
isdensity: false

Fitting a histogram to all-equal integer values works, but not for all-equal float values – see the 0 weight in the second example. The bin edges seem to be computed incorrectly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions