Asked by zozo
on 14 Aug 2012

I have following two histograms:

The Histogram-1 is more spread out as compared to Histogram-2. How can I measure the steepness or gradient of histogram from one of the bins? (say from a bin having frequency=0.4) ??

Is there any parameter defined for this measure?

%<<<<---additional info--->>>>%

@cyclist: Those histograms are from 2 different ECG signals recorded during irregular heart beat. So, based on the histograms, Iam trying to design automatic thresholding algorithm, to de-noise the signal and have only dominant activations. The figure below is one of the example:

In the above example, I have manually entered the threshold limits[-0.2,0.2]. Now,I want to somehow make it automatic, i.e. data-dependent. Since I observe different signals produce different histograms, different thresholds are required. So, I think the degree of steepness(slope) would somehow help me.

Answer by Peter Perkins
on 14 Aug 2012

There are a few things to note about these two histograms. They have (at least approximately) the same mean. They are both (at least approximately) symmetric. The first has a larger range. The second seems to be more peaked (though it's hard to tell because of the different range.

You refer to "steepness". It's not clear what you mean by that, especially since you refer to steepness at one bin. Histograms are a bad way to look at "local" properties of data, since they are strongly dependent on how you choose the bins. So I can't/won't comment on "steepness" at one particular bin.

But it seems like you might want to compute some simple descriptive statistics on each of these data sets. If you have the Statistics Toolbox, the MEAN and SKEWNESS functions will, as I observed above, return more or less zero in both cases. The STD and KURTOSIS functions are perhaps what you are looking for. The former will of course return a larger value for the first data set. KURTOSIS will give you an indication of which data set is more "peaked", which is to say, puts more weight at the peak and in the tails as opposed to the mid-range.

If kurtosis is what you are asking about, one thing you might do to visualize it is to standardize both data sets using ZSCORE, and then plot smooth density estimates from KSDENSITY of both in the same figure. Something like

x1 = randn(1000,1);

x2 = trnd(3,1000,1);

ksdensity(zscore(x1))

hold on, ksdensity(zscore(x2)); hold off

The Distribution Fitting Tool, dfittool, will probably make comparing these two data sets easier.

Sign in to comment.

Answer by Walter Roberson
on 14 Aug 2012

zozo
on 14 Aug 2012

Thank you. And what if the mean is different? is there any mathematical relation to measure it?

the cyclist
on 14 Aug 2012

I don't think it is quite this simple, and I could easily create an example (admittedly a pathological one) where it is not true. For example, take the zozo's bottom example, add one outlier very far away (to boost the standard deviation arbitrarily high), then shift the whole distribution to put the mean back to where it was.

@zozo, I suggest you add some more detail to your question, to describe what it is that you are trying to do with this "steepness" you are trying to measure. Your problem does not seem very well defined as it stands.

zozo
on 14 Aug 2012

@cyclist: I have added some more info in my question

Sign in to comment.

Answer by Stephen
on 14 Aug 2012

if he had an exponential distribution vs. a normal, there's different 'steepness' in each one depending on what you examine, but he means the slope of the distribution at a point then maybe this will help:

[y,x] = hist(data,100);

slopes = diff(y);

steepness = slopes( x==0.4 );

I would go further to say that if you know the distribution, then fit it to whatever it is and then calculate your answer from the model. If you always have normal distributions, just get the mean and variance and plug in an x value to y = exp(-x^2/sig^2)/(sqrt(2*pi)*sig) and take the diff of that...

You can also use a Parzen window to approximate your distribution if you don't know what it is. I won't go into that however, it's easy enough to figure out.

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## Image Analyst (view profile)

Direct link to this comment:https://de.mathworks.com/matlabcentral/answers/45983-steepness-of-a-histogram#comment_94555

## zozo (view profile)

Direct link to this comment:https://de.mathworks.com/matlabcentral/answers/45983-steepness-of-a-histogram#comment_94601

Sign in to comment.