Index
HistogramBinnings.HistogramBinnings
HistogramBinnings.LinEdgeVector
HistogramBinnings.LogEdgeVector
StatsAPI.fit
StatsBase.midpoints
Types and Functions
HistogramBinnings.HistogramBinnings
— ModuleModule 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
HistogramBinnings.LinEdgeVector
— TypeLinEdgeVector{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)
HistogramBinnings.LogEdgeVector
— TypeLogEdgeVector{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)
StatsAPI.fit
— Methodfit(::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)
StatsBase.midpoints
— Methodmidpoints(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.