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
17
votes
2 answers

Detect the two highest Peaks from Histogram

I was trying to understand on how to detect the two peaks from the histogram. There can be multiple but I need to pick the two highest. Basically what I need to to is that although I will have these peaks shifted left or right, I need to get hold of…
Wajih
  • 793
  • 3
  • 14
  • 31
16
votes
2 answers

How to COUNT duplicate rows?

I want to be able to create a histogram out of a tuple containing two integers values. Here it is the query: SELECT temp.ad_id, temp.distance as hits FROM ( 'UNION ALL .join(cupound_query)' # python ) as temp GROUP BY temp.ad_id,temp.distance…
fabrizioM
  • 46,639
  • 15
  • 102
  • 119
16
votes
1 answer

how to plot 2 histograms side by side?

I have 2 dataframes. I want to plot a histogram based on a column 'rate' for each, side by side. How to do it? I tried this: import matplotlib.pyplot as plt plt.subplot(1,2,1) dflux.hist('rate' , bins=100) plt.subplot(1,2,2) dflux2.hist('rate'…
Mark Ginsburg
  • 2,139
  • 4
  • 17
  • 31
16
votes
5 answers

How do you use hist to plot relative frequencies in R?

How do you use hist() to plot relative frequencies in R? If I do the following, I will get a density plot, but I want a relative frequency plot: a <- c(0,0,0,1,1,2) hist(a, freq=FALSE) I want to see a histogram with the following relative…
Will
  • 812
  • 3
  • 11
  • 21
16
votes
1 answer

Plotting Histogram with given x and y values

I am trying to plot a histogram that lines up every x value with the y value on the plot. I have tried to use multiple resources, but unfortunately I wasn't able to find anything. This is the best way I could code to make a histogram. x =…
krazzy
  • 179
  • 1
  • 1
  • 10
16
votes
4 answers

Find dominant color on an image

I want to find dominant color on an image. For this, I know that I should use image histogram. But I am not sure of image format. Which one of rgb, hsv or gray image, should be used? After the histogram is calculated, I should find max value on…
zakjma
  • 2,030
  • 12
  • 40
  • 81
16
votes
3 answers

How to plot histogram/ frequency-count of a vector with ggplot?

I want to plot with ggplot the frequency of values from a numeric vector. With plot() is quite straight forward but I can't get the same result with ggplot. library(ggplot2) dice_results <- c(1,3,2,4,5,6,5,3,2,1,6,2,6,5,6,4) …
CptNemo
  • 6,455
  • 16
  • 58
  • 107
16
votes
4 answers

Methods to vectorise histogram in SIMD?

I am trying to implement histogram in Neon. Is it possible to vectorise ?
Rugger
  • 373
  • 3
  • 10
16
votes
2 answers

R: saving ggplot2 plots in a list

I am writing a R code that allows users to select columns from a data and plots histograms for each of them. Hence, I am using a 'for' loop to generate the required number of plots using the ggplot2 library and save them in a single list. But the…
tejas_kale
  • 593
  • 2
  • 7
  • 21
16
votes
3 answers

Cumulative histogram has last point at y=0

I am creating histogram with pylab.hist(data,weights,histtype='step',normed=False,bins=150,cumulative=True) getting (there are other plots, which are irrelevant now) the violet line Why is the histogram dropping to zero at the end again?…
eudoxos
  • 18,545
  • 10
  • 61
  • 110
15
votes
1 answer

Drawing Histogram in OpenCV-Python

I was just trying to draw histogram using new OpenCV Python interface ( cv2 ). Below is the code i tried: import cv2 import numpy as np import time img = cv2.imread('zzz.jpg') h = np.zeros((300,256,3)) b,g,r = cv2.split(img) bins =…
Abid Rahman K
  • 51,886
  • 31
  • 146
  • 157
15
votes
2 answers

plot histogram of datetime.time python / matplotlib

I am trying to plot a histogram of datetime.time values. Where these values are discretized into five minute slices. The data looks like this, in a list: ['17:15:00', '18:20:00', '17:15:00', '13:10:00', '17:45:00', '18:20:00'] I would like to plot…
Spacen Jasset
  • 938
  • 2
  • 11
  • 21
15
votes
4 answers

Make y-axis logarithmic in histogram using R

Hi I'm making histogram using R, but the number of Y axis is so large that I need to turn it into logarithmic.See below my script: hplot<-read.table("libl") hplot pdf("first_end") hist(hplot$V1, breaks=24, xlim=c(0,250000000),…
LookIntoEast
  • 8,048
  • 18
  • 64
  • 92
15
votes
3 answers

Histogram matching of two colored images in matlab

Anyone knows how to perform RGB histogram matching on two colored images? for example this is an image to be re-mapped: and this is a target image Then the RGB remapped image look like this here is what I did so far, in this code I took two color…
Glove
  • 960
  • 6
  • 17
  • 30
15
votes
2 answers

How to add mean, and mode to ggplot histogram?

I need to add a mean line and the value of the mode for example to this kinds of plots: I use this for calculate the number of bins: bw <- diff(range(cars$lenght)) / (2 * IQR(cars$lenght) / length(cars$lenght)^(1/3)) And the…
Borja_042
  • 1,071
  • 1
  • 14
  • 26