Plugging a new value to ksdensity

I have a one dimensional vector r sampled from some (unknown) probability distribution and fit ksdensity to compute its pdf.
Then, I want to obtain a fitted value of f on a new scalar (say, x_new), which is not a member of xi.
How can I do it?
For instance,
r = randn(100,1);
[f,xi]=ksdensity(r);
x_new=1.1;

 採用された回答

Torsten
Torsten 2024 年 12 月 27 日
編集済み: Torsten 2024 年 12 月 28 日

0 投票

rng("default")
r = randn(100,1);
x_new = 1.1;
f = ksdensity(r,x_new)
f = 0.2331
or
rng("default")
r = randn(100,1);
f = @(x)ksdensity(r,x);
x_new = 1.1;
y = f(x_new)
y = 0.2331

1 件のコメント

Roy0014
Roy0014 2024 年 12 月 28 日
Thank you so much!

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

その他の回答 (0 件)

製品

リリース

R2023b

質問済み:

2024 年 12 月 27 日

コメント済み:

2024 年 12 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by