How to get kse or ksdensity as definable or anonymous function of x

1 回表示 (過去 30 日間)
David Gillcrist
David Gillcrist 2024 年 10 月 1 日
編集済み: Torsten 2024 年 10 月 1 日
From what I can tell both kse and ksdensity are used to get a smoothly defined probability distribution function from vector of finite data. Is there a way to get MATLAB to produce the actual function as the output instead of finite set of input/output vectors? I need to be able to call on the kernal density estimator at an arbitrary point in my domain and I'd prefer not to just interpolate between the values provided. Is there a functionality of either of these two that gives the true function/estimator or do I need to write my own code to accomplish this?
  3 件のコメント
David Gillcrist
David Gillcrist 2024 年 10 月 1 日
Either I have a misunderstanding about kernal density estimation, or I don't quite understand your response. Is it not the case that the result of producing a KSE (at least using a Gaussian smoothing function which is the default for kse) is a smoothly defined function?
Torsten
Torsten 2024 年 10 月 1 日
編集済み: Torsten 2024 年 10 月 1 日
You can define the function as
f = @(y) ksdensity(x,y)
e.g.
rng('default') % For reproducibility
x = [randn(30,1); 5+randn(30,1)];
f = @(y)ksdensity(x,y);
fy = f(1.34)
fy = 0.1094
Of course, the density function will always be recomputed this way.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeExploration and Visualization についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by