Index

Types and Functions

HistogramBinnings.HistogramBinningsModule

Module for constructing edge vectors for histograms.

Examples

using StatsBase 
using HistogramBinnings

h = fit(Histogram, LogEdgeVector, values)

# or with a custom edge vector

edges = LogEdgeVector(lo = 1, hi = 1_000_000, nbins = 60)
h = append!(Histogram(edges), values)

Exports

This module exports the following types and functions:

  • LogEdgeVector
  • LinEdgeVector
  • midpoints
source
HistogramBinnings.LinEdgeVectorType
LinEdgeVector{T}(; lo = 1, hi = 10, nbins::Integer) where T <: Real

Construct a linearly spaced edge vector of type T. The edges are spaced evenly in linear space. lo and hi are the lower and upper limits of the histogram. nbins is the number of bins.

Examples

using HistogramBinnings

edges = LinEdgeVector(lo = 1, hi = 1_000_000, nbins = 60)
source
HistogramBinnings.LogEdgeVectorType
LogEdgeVector{T}(; lo = 1, hi = 10, nbins::Integer) where T <: Real

Construct a logarithmically spaced edge vector of type T. The edges are spaced evenly in log space. lo and hi are the lower and upper limits of the histogram. nbins is the number of bins.

Examples

using HistogramBinnings

edges = LogEdgeVector(lo = 1, hi = 1_000_000, nbins = 60)
source
StatsAPI.fitMethod
fit(::Type{Histogram}, ::Type{T}, vs::AbstractVector;
    nbins = sturges(length(vs)),
    lo = minimum(vs),
    hi = maximum(vs)
) where T <: AbstractEdgeVector

Fit a histogram with edges T to the data vs.

T is either LogEdgeVector or LinEdgeVector. The edges are Int if the vs are Int otherwise they are Float64. lo and hi are the lower and upper limits of the histogram. nbins is the number of bins.

Examples

using StatsBase, HistogramBinnings
using Distributions

vs = floor.(Int, rand(Pareto(), 10000000))

h = fit(Histogram, LogEdgeVector, vs)

# or 

edges = LogEdgeVector(lo = 1, hi = 1_000_000, nbins = 60)
h = append!(Histogram(edges), vs)
source
StatsBase.midpointsMethod
midpoints(r::AbstractEdgeVector{T}) where T

Return the midpoints of the bins in r. The calculation of the midpoints depends on the type of the edges and whether they are linearly or logarithmically spaced.

source