# Hist() and hits() in Julia?

**URL:** <https://discourse.julialang.org/t/hist-and-hits-in-julia/1224>\
**Category:** Statistics\
**Tags:** question\
**Created:** [December 30, 2016, 11:03pm UTC](https://discourse.julialang.org/t/hist-and-hits-in-julia/1224 "2016-12-30T23:03:08Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Evizero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evizero/32/10118_2.png) [@Evizero](https://discourse.julialang.org/u/Evizero)\
**Post date:** [December 30, 2016, 11:14pm UTC](https://discourse.julialang.org/t/hist-and-hits-in-julia/1224/2 "2016-12-30T23:14:20Z")

</div>

You can use [StatsBase](https://github.com/JuliaStats/StatsBase.jl) for this

```julia
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](http://statsbasejl.readthedocs.io/en/latest/empirical.html)

---

_[View the full topic](https://discourse.julialang.org/t/hist-and-hits-in-julia/1224)._
