Index
HistogramBinnings.HistogramBinningsHistogramBinnings.LinEdgeVectorHistogramBinnings.LogEdgeVectorStatsAPI.fitStatsBase.midpoints
Types and Functions
HistogramBinnings.HistogramBinnings — Module
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:
LogEdgeVectorLinEdgeVectormidpoints
HistogramBinnings.LinEdgeVector — Type
LinEdgeVector{T}(; lo = 1, hi = 10, nbins::Integer) where T <: RealConstruct 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)HistogramBinnings.LogEdgeVector — Type
LogEdgeVector{T}(; lo = 1, hi = 10, nbins::Integer) where T <: RealConstruct 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)StatsAPI.fit — Method
fit(::Type{Histogram}, ::Type{T}, vs::AbstractVector;
nbins = sturges(length(vs)),
lo = minimum(vs),
hi = maximum(vs)
) where T <: AbstractEdgeVectorFit 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)StatsBase.midpoints — Method
midpoints(r::AbstractEdgeVector{T}) where TReturn 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.