Borrar filtros
Borrar filtros

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

24 visualizaciones (últimos 30 días)
David Gillcrist
David Gillcrist el 1 de Oct. de 2024 a las 16:40
Editada: Torsten el 1 de Oct. de 2024 a las 18:22
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 comentarios
David Gillcrist
David Gillcrist el 1 de Oct. de 2024 a las 18:08
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 el 1 de Oct. de 2024 a las 18:20
Editada: Torsten el 1 de Oct. de 2024 a las 18:22
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.

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by