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

Javascript D3 Histogram: thresholds producing wrong number of bins

I'm in the process of creating a histogram JS script using D3, and it all seems to be working correctly... except for the number of bins. Following is the relevant part of my code: //Define the scales for the x and y attributes var x =…
user7859002
  • 43
  • 1
  • 6
2
votes
2 answers

Add numpy array elements/slices with same bin assignment

I have some array A, and the corresponding elements of the array bins contain each row's bin assignment. I want to construct an array S, such that S[0, :] = (A[(bins == 0), :]).sum(axis=0) This is rather easy to do with np.stack and list…
DathosPachy
  • 742
  • 1
  • 6
  • 17
2
votes
1 answer

How to make a histogram of tensor columns in tensorflow

I have a batch of images as a tensor of size [batch_size, w, h]. I wish to get a histogram of the values in each column. This is what I came up with (but it works only for the first image in the batch and its also very slow): global_hist = [] net…
itzik Ben Shabat
  • 927
  • 11
  • 24
2
votes
2 answers

R ggplot histogram bars in descending order

I don't get how to make the bars of an histogram to appears in descending order with ggplot. Heres my code with a dataframe that everyone can use : library(ggplot2) library(scales) chol <-…
PiecesOfMagics
  • 69
  • 1
  • 3
  • 9
2
votes
3 answers

Using hist in Matlab to compute occurrences

I am using hist to compute the number of occurrences of values in a matrix in Matlab. I think I am using it wrong because it gives me completely weird results. Could you help me to understand what is going on? When I run this piece of code I get…
TEX
  • 2,249
  • 20
  • 43
2
votes
3 answers

Animation of histograms in subplot

I have the following animated subplots that simulate histograms of four different distributions: import numpy from matplotlib.pylab import * import matplotlib.animation as animation n = 100 # generate 4 random variables from the random, gamma,…
horcle_buzz
  • 2,101
  • 3
  • 30
  • 59
2
votes
1 answer

ggplot does not color histogram by group

I am learning R and I am trying to create a composite histogram that will contain the histograms of three groups, as defined by the values of the column 'cluster' in the dataframe. The data look like this: TOTAL_Estimated_Collateral_value_sum…
ak7
  • 175
  • 1
  • 4
  • 8
2
votes
1 answer

Choose type of ggplot2 histogram (frequency or density) within a function

long-time reader, first-time question-writer...I have a function that puts takes in data and spits out a ggplot2 histogram with some specific formatting. I'm trying to edit this function so that one of the function parameters can specify whether I…
2
votes
1 answer

Plot prebinned data with correct x axis labelling

I have a series of files output from another code that contains pre-binned data which I would like to plot up using matplotlib. A simple example of the contents from one of these files would be: hist_file=[ 0.00000000e+00, 1.52915100e+24, …
Matthew
  • 33
  • 1
  • 5
2
votes
0 answers

Is it possible to make a pirateplot using frequencies instead of densities in R?

I am searching and trying the following plot in R for ages, but nothing seems to work. What I want is a quantitative variable in the Y axis and a categorical variable in the X axis, and just an horizontal histogram (of the Y variable) for each…
R_fan
  • 21
  • 1
2
votes
2 answers

How to create a histogram plot of a histogram?

Im creating histograms using two scripts, one is matlabs own hist function and another is a script I downloaded. The script I downloaded takes the absolute min and max values and generates a histogram between that. But the issue is that unlike…
StuckInPhDNoMore
  • 2,507
  • 4
  • 41
  • 73
2
votes
1 answer

2 Y axis histogram (normal frequency vs relative frequency)

I would like your help, please. I have this 2 plots, separately. One is normal frequency and the other one, with exactly the same data, is for relative frequency. Can you tell me how can i join them in a single plot with 2 y axis ( frequency and…
Ana Raquel
  • 155
  • 3
  • 13
2
votes
2 answers

Defined interval in R by cut() and make a histogram plot

I am struggling to figure it out how to use cut() function to define interval of my data of interest by 12 months. I read this post R - Cut by Defined Interval. But it dose not help what I am looking for. say, I have a set of data name months which…
Daniel
  • 1,202
  • 2
  • 16
  • 25
2
votes
1 answer

vImageBuffer_InitWithCGImage Memory Leak in Swift 3

I am trying to get histogram calculation. Everything works fine, except following method shows an immense memory leak when profiled in Instruments. Every time following method is called, it uses 200-300 MB of memory and never releases: func…
Gizmodo
  • 3,151
  • 7
  • 45
  • 92
2
votes
1 answer

How To Make Histogram Bins in R-Studio Only Use Integers

I am attempting to create several histograms that display the effects a drug has on the frequency of heart attacks. Currently, R is organizing my data into the bins [0 - 0.5, 0.5 - 1.0, 1.0 - 1.5, etc.], but I would like for it to only use integer…
Guy Cerretti
  • 21
  • 1
  • 2
1 2 3
99
100