How to create a pdf from the histogram

28 ビュー (過去 30 日間)
MechenG
MechenG 2025 年 5 月 4 日
コメント済み: MechenG 2025 年 5 月 10 日
Hi,
My data is stored in x3 array (also attachesd here). where, x3 (1,:) - input; x3 (2,:) - output. I need to generate pdf from this data. May I know how to generate histogram and pdf from this data.

採用された回答

the cyclist
the cyclist 2025 年 5 月 4 日
You can use the histogram function to create and plot a histogram.
You can use the ksdensity function to estimate a non-parametric fit to the probability density function, and then the plot function to plot it.
  17 件のコメント
the cyclist
the cyclist 2025 年 5 月 10 日
編集済み: the cyclist 2025 年 5 月 10 日
You need to read about and understand the method more. The KS curve is going to be incorporating data density from more than one of your discrete values.
How far left and right each point looks is determined by the kernel bandwidth. For example, look what happens when I make it very narrow:
% Load the data
load matlab.mat
% Non-parametric fit to the data
[f,x] = ksdensity(b,"BandWidth",0.3);
% Calculate the normalization that will convert the KS density
% to the same scale as histfit()
dx = x(2) - x(1);
count = numel(b);
% Plot
figure
hold on
histfit(b)
plot(x,f*dx*count,"LineWidth",2)
legend(["data","histfit","ksdensity"])
MechenG
MechenG 2025 年 5 月 10 日
Ok. Now I got it. Thanks.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by