Questions tagged [histogram]

In statistics, a histogram is a graphical representation, showing a visual impression of the distribution of data.

In statistics, a histogram is a graphical representation, showing a visual impression of the distribution of data. It is an estimate of the probability distribution of a continuous variable and was first introduced by Karl Pearson. A histogram consists of tabular frequencies, shown as adjacent rectangles, erected over discrete intervals (bins), with an area equal to the of the observations in the interval. The height of a rectangle is also equal to the frequency density of the interval, i.e., the frequency divided by the width of the interval. The total area of the histogram is equal to the number of data. A histogram may also be normalized displaying relative frequencies. It then shows the proportion of cases that fall into each of several categories, with the total area equaling 1. The categories are usually specified as consecutive, non-overlapping intervals of a variable. The categories (intervals) must be adjacent, and often are chosen to be of the same size.

Histograms are used to plot density of data, and often for density estimation: estimating the probability density function of the underlying variable. The total area of a histogram used for probability density is always normalized to 1. If the length of the intervals on the x-axis are all 1, then a histogram is identical to a relative frequency plot.

In scientific software for statistical computing and graphics, The function hist generates a histogram. It can also optionally scale it so that its total area is 1. This puts it in the right scale if one want to overlay a probability density curve.

More about it here : histogram wiki

6663 questions
10
votes
1 answer

Monte Carlo Simulation with Python: building a histogram on the fly

I have a conceptual question on building a histogram on the fly with Python. I am trying to figure out if there is a good algorithm or maybe an existing package. I wrote a function, which runs a Monte Carlo simulation, gets called 1,000,000,000…
marillion
  • 10,618
  • 19
  • 48
  • 63
10
votes
1 answer

How can I set dataless areas of a hist2d plot to the zero-value color?

I'm tracking a subject's gaze over a specified area of a computer screen. I'm constructing gaze heatmaps using pyplot's hist2d function. Here's a simple example: figure() hist2d(xval, yval, bins=1000) xlim([-6, 6]) ylim([-4.5, 4.5]) As you can…
Louis Thibault
  • 20,240
  • 25
  • 83
  • 152
10
votes
1 answer

matplotlib: histogram and bin labels

I'm trying to plot a histogram with bar chart, and I'm having difficulties figuring out how to align the x-axis labels with the actual bins. The code below generates the following plot: as you can see, the end of each x-label is not aligned to the…
dimka
  • 4,301
  • 11
  • 31
  • 36
10
votes
3 answers

Stacked histogram from already summarized counts using ggplot2

I would like some help coloring a ggplot2 histogram generated from already-summarized count data. The data are something like counts of # males and # females living in a number of different areas. It's easy enough to plot the histogram for the…
Paul J Hurtado
  • 572
  • 1
  • 4
  • 12
10
votes
4 answers

Calculating peaks in histograms or density functions

There seem to be a lot of "peaks in density function" threads already, but I don't see one addressing this point specifically. Sorry to duplicate if I missed it. My problem: Given a vector of 1000 values (sample attached), I would like to identify…
David Roberts
  • 617
  • 1
  • 11
  • 23
10
votes
2 answers

Formatting histogram x-axis when working with dates using R

I am in the process of creating an epidemic curve (histogram of number of cases of a disease per day) using R, and am struggling a little with formatting the x-axis. I am aware that ggplot gives very nice graphs and easily manipulatable axes (…
Jonny
  • 2,703
  • 2
  • 27
  • 35
10
votes
2 answers

GNUPLOT Each Histogram Bar with different color

I want to visualize the amount of different colors of a bitmap file. My Datasheet looks like: 1 163073164 4 185122087 3 255242000 8 255255255 3 000162232 1 181230029 1 127127127 1 136000021 3 200191231 I want to draw each color bar with its own…
user1553847
  • 111
  • 1
  • 4
10
votes
1 answer

How can I create a histogram for all variables in a data set with minimal effort in R?

Exploring a new data set: What is the easiest, quickest way to visualise many (all) variables? Ideally, the output shows the histograms next to each other with minimal clutter and maximum information. Key to this question is flexibility and…
Rico
  • 1,998
  • 3
  • 24
  • 46
10
votes
1 answer

Using gnuplot for stacked histograms

I am trying to create a stacked histogram with the following data: 8.01 1 5 1 8.02 3 5 1 8.03 4 4 1 8.04 3 4 1 8.05 1 2 1 I have tried to adapt the script from the 4th example and at the moment I'm using…
Mike Kwan
  • 24,123
  • 12
  • 63
  • 96
9
votes
5 answers

Simple histogram generation of integer data in C#

As part of a test bench I'm building, I'm looking for a simple class to calculate a histogram of integer values (number of iterations taken for an algorithm to solve a problem). The answer should be called something like this: Histogram my_hist =…
Jon Cage
  • 36,366
  • 38
  • 137
  • 215
9
votes
2 answers

How to create a histogram using MySQL

I am trying to create a histogram data using following query: SELECT FLOOR(Max_Irrad/10) AS bucket, COUNT(*) AS COUNT FROM marctest.test_summarynimish where Lcu_name='Allegro' and Lcu_Mode='Standard' GROUP BY bucket; following is the result…
dna
  • 483
  • 3
  • 10
  • 32
9
votes
4 answers

How can I create a histogram from aggregated data in R?

I have a data frame that has a format like the following: Month Frequency 2007-08 2 2010-11 5 2011-01 43 2011-02 52 2011-03 31 2011-04 64 2011-05 73 I would like to create a histogram from this data, using X bins…
Stephen Booher
  • 6,522
  • 4
  • 34
  • 50
9
votes
2 answers

Python: Histogram with area normalized to something other than 1

Is there a way to tell matplotlib to "normalize" a histogram such that its area equals a specified value (other than 1)? The option "normed = 0" in n, bins, patches = plt.hist(x, 50, normed=0, histtype='stepfilled') just brings it back to a…
Pawin
  • 368
  • 1
  • 3
  • 7
9
votes
3 answers

How to Plot a Horizontal Histogram in MATLAB?

I looked and couldn't find an answer for this question, so here goes. I have some data (a 1 X 1000 vector called data) that I would like to plot the histogram information for. If I use the histogram(data) command then I get a nice enough histogram…
Jimmy
  • 4,419
  • 6
  • 21
  • 30
9
votes
2 answers

How to add gaussian curve to histogram created with qplot?

I have question probably similar to Fitting a density curve to a histogram in R. Using qplot I have created 7 histograms with this command: (qplot(V1, data=data, binwidth=10, facets=V2~.) For each slice, I would like to add a fitting gaussian…
mkk
  • 7,583
  • 7
  • 46
  • 62