Plugging a new value to ksdensity

13 visualizaciones (últimos 30 días)
Roy0014
Roy0014 el 27 de Dic. de 2024 a las 21:56
Comentada: Roy0014 el 28 de Dic. de 2024 a las 18:01
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;

Respuesta aceptada

Torsten
Torsten el 27 de Dic. de 2024 a las 23:56
Editada: Torsten el 28 de Dic. de 2024 a las 0:21
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

Más respuestas (0)

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by