Is there a way to normalizing a probability density function / keep the density values between 0 and 1?

조회 수: 94 (최근 30일)
I am creating a distribution for my data set, so I’m creating a distribution object first then a pdf from the distribution object. I was wondering if there is a way keep my density values between 0 and 1. I understand that despite the density values the curve still integrates to 1 and its no issue but it'd be nice if there was a way to limit the range between 0 and 1.
I've considered dividing my density value by the max density value to get them to be between 0 and 1 but i am afraid that may have some ramifications.
Test_Data;
dist_object = fitdist(Test_Data,"Normal");
dist_pdf = pdf(dist_object,Test_Data);
Normal_hist = histfit(Test_Data,20,'normal');
Normal_hist(1).FaceColor = [.8 .8 1];
title('normal pdf');

채택된 답변

Jeff Miller
Jeff Miller 2021년 11월 17일
Dividing by the max density value would have the unfortunate ramification that the resulting function would no longer be a density function because it would no longer integrate to 1.
It is a common misconception that pdf values should be between 0 and 1 like probabilities. As you said, though, the actual requirement for a pdf is that it integrates to one.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2021년 11월 18일
You are fitting a normal distribution, which implies infinite extent.
In any case where the standard deviation is greater than 1/sqrt(2*pi) then no element of the pdf will be greater than 1 and no rescale is required. If the standard deviation is smaller than that then the pdf at the location of the mean will be greater than 1 and any rescale will prevent the integral from working. You would need to increase the standard deviation to prevent that.
However, I wonder whether your data is truly sampling an infinite distribution. I have not looked at the data, but when a set of data is involved it is far more common that the situation involves a finite span... and finite spans are incompatible with normal distribution. I would ask whether perhaps you should be looking for a beta distribution instead of a normal distribution.
  댓글 수: 4
Walter Roberson
Walter Roberson 2021년 11월 25일
I have noticed you editing your comment a couple of times, but I have not noticed any changing in the wording ?
"My question to you is, Is there any way to at least scale it so that it looks reasonable"
NO.
In some cases where you have most of your probability in small region compared to the overall span, then maybe it makes sense to truncate the distribution, chopping off the ends and multiplying the pdf by enough to raise the integral of the remaining range to 1 over the remaining range. But if you do that, then you increase the probabilities in that range, and if you already have pdf values greater than 1, then that would get you pdf values that were even more greater than 1.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by