Peak in probability distribution moves in normpdf when changing lower bound for input vector

4 ビュー (過去 30 日間)
I am trying to compare some data with a computed normal approximation to the dataset. I computed the sample mean and standard deviation the normal ways (mean and std)', I've come up with 40K and 6K (to 1 SF). When I try to plot this distribution using a simple statement:
plot(normpdf(10e3:70e3,40e3,6e3))
It shows the peak in the probability distribution as 30K! When I use a different lower bound for the vector to plot, it moves the probability peak further (e.g., if I start at 20K, the peak moves to 20K).
It appears that the peak in the distribution is appearing at $MEAN- /$LOWER_BOUND, as when I set the lower bound to zero, I get the expected behavior of a normal PDF centered at 40K. The standard deviation of 6K appears to be correctly used in all cases.
Similar behavior is manifested when using a negative lower bound: using the below command changes the peak in the probability displayed to 60K
plot(normpdf(-20e3:70e3,40e3,6e3))

採用された回答

David Goodmanson
David Goodmanson 2025 年 4 月 14 日
編集済み: David Goodmanson 2025 年 4 月 14 日
Hi Chris, try
x = 10e3:70e3;
plot(x,normpdf(x,40e3,6e3))
The problem occurs because if you create y = f(x) and use plot(y), the plot command has no way of knowing what the x array might have been. Without an explicit x input, the x axis is taken to be the y array indices 1:length(y).
  1 件のコメント
Chris Ostrom
Chris Ostrom 2025 年 4 月 14 日
That makes a lot of sense, I assumed that the information somehow was transmitted between the functions. I can confirm that plotting the array and NORMPDF(array) does indeed provide the expected results.
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by