It depends on how you want to bin your data and what kind of data you have.
The idea of hist function is similar to stacks of coins: Let's say you have a bag of coins and after you separate them by values and stack on one another, you will get different heights. The hist function does the same.
data=[1 3 5 7 4 8 0 1 3];
If you want to distribute your data into 10 bins, you would create a new array of size 10:
then, you would run a forloop to count how many times you encounter in a particular value:
There could be another case. Let's say you want to distribute your data into 5 bins only (0 and 1 go in the 1st bin, 2 and 3 go in the 2nd...). In this case, you would run the same loop but with more complicated conditioning:
You can design your own hist function to fit you needs