Hist() and hits() in Julia?

Given a set of elements, I would love to efficiently partition their numerical values into bins, and then return the count in each bin, as well as the bin edges.

MATLAB used to have super simple functions for this (i.e. hist, and histc). I wrote my own (quick and dirty) code. Which is the best (and simplest) way to do it ?

Note: I don’t care about plotting - I need to do subsequent analysis on the bins and the counts.
Thanks for your patience and help.

You can use StatsBase for this

julia> using StatsBase

julia> result = fit(Histogram, randn(1000))
StatsBase.Histogram{Int64,1,Tuple{FloatRange{Float64}}}
edges:
  -4.0:1.0:4.0
weights: [2,24,131,361,342,129,10,1]
closed: right

Replace the randn(1000) in the code above with the vector your are working with.
You can access the properties of the result using result.edges and result.weights.

See http://statsbasejl.readthedocs.io/en/latest/empirical.html

Tnx!!! Documentation is unfortunately ultra-condensed.

I failed to understand how to run a simple test against the theory

data = randn(10000);

x = -10:0.1:10;
y = 1./sqrt(2π) * exp(-0.5*x.^2);

Anyway, thank you for your reply and competent advise.
M