histogramjulia# Histogram calculation in julia-lang

refer to julia-lang documentations :

hist(v[, n]) → e, counts

Compute the histogram of v, optionally using approximately n bins. The return values are a range e, which correspond to the edges of the bins, and counts containing the number of elements of v in each bin. Note: Julia does not ignore NaN values in the computation.

I choose a sample range of data

```
testdata=0:1:10;
```

then use hist function to calculate histogram for 1 to 5 bins

```
hist(testdata,1) # => (-10.0:10.0:10.0,[1,10])
hist(testdata,2) # => (-5.0:5.0:10.0,[1,5,5])
hist(testdata,3) # => (-5.0:5.0:10.0,[1,5,5])
hist(testdata,4) # => (-5.0:5.0:10.0,[1,5,5])
hist(testdata,5) # => (-2.0:2.0:10.0,[1,2,2,2,2,2])
```

as you see when I want 1 bin it calculates 2 bins, and when I want 2 bins it calculates 3.

why does this happen?

Solution

As the person who wrote the underlying function: the aim is to get bin widths that are "nice" in terms of a base-10 counting system (i.e. 10^{k}, 2×10^{k}, 5×10^{k}). If you want more control you can also specify the exact bin edges.

- Histogram with a mean line in same spot
- How can i make a stacked multiple density plot with ggplot?
- How to get the cumulative distribution function with NumPy?
- ggplot histogram with custom bin limits and counts
- How to add summary statistics next to a legend in ggplot2?
- Plotting weighted histograms with weighted KDE (kernel density estimate)
- promethus: native histograms
- How to make binning consistent in R
- Multi-axis x with matplotlib python
- Looking for a Histogram Binning algorithm for decimal data
- Pandas plot histogram of value counts per group
- ggplot draw multiple plots by levels of a variable
- How to create histogram with aligned monthly bins?
- Binning for a histogram in python
- How to replace the dot-dot notation in `ggplot2::geom_histogram(`y = ..density..`)`?
- Is there a way to make a histogram in R to display both the frequency of years an event occurred and a specific detail about that event?
- I need the age of my agents before they die to create a list and histogram
- How to set bin ranges on a histogram in MatPlotLib using a list of values?
- Quantiles function in BigQuery Standard SQL
- Formatting histogram x-axis when working with dates using R
- python histogram, looking messy and uneven
- R histogram store the calculated bin values
- apply numpy.histogram to multidimensional array
- manually plot hist(X, freq = FALSE)
- How to create a long-form data frame from a 3D array (for a facet plot of histograms)
- ggplot() lines transparency
- How to make a percentage plot histogram in R / ggplot
- Can't get y-axis on Matplotlib histogram to display probabilities
- How to create a boost::histogram as a class member and initialize it in the class constructor?
- How to fit "Negative Binomial" Distribution on a histogram using ggplot2()?