Kernel Density Estimation - Find the pdf and perform integration and derivative on this function
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have performed KDE on data:
[f,xi] = ksdensity(data,'bandwidth',0.5,'Function','pdf');
I have the following code which aims to solve for theta - roots of first derivative of the pdf. What I did was plot the pdf from kernel estimation, using Basic Fitting to obtain the function, then solve for theta.
syms theta %create symbolic variable theta
assume(theta,'real') %theta is real
pf = poly2sym(fit.coeff,theta); %calling our fitted polynomials
g = diff(pf,theta);
g0=solve(g,theta);
theta = double(g0);
However, Basic Fitting doesn't fit very well with the pdf. How can I obtain pdf and take derivative without producing too much residuals? (see pic)
Additionally, theta has to follow three conditions: -smaller than the highest pdf value -pdf evaluation of theta must be smaller than 0.8 times of that of the highest pdf value -integral from min x value to theta of pdf must be larger than 0.05
θ < μ, f(θ)<0.8·f(μ) and ∫ f (x)dx > 0.05 from min x to θ.
Is there a way to incorporate loop and boolean to automate solving for theta.
4 comentarios
Christoph
el 11 de En. de 2018
ksdensity is a non-parametric fitting method. Basically, you seem to fit a (10th degree) polynomial to your data, convert the polynomial to a sym object, determine a zero of its derivative and then again convert to double. You do not need the symbolic detour here, you can just use polyder + roots to obtain all zeros. Tam Ho´s comment recommends fitting a spline, and indeed, you could do that and use fnder() for computing derivatives. Another approach would be to use traditional signal processing approach, smooth the data and use a functions such as findpeaks on a numerical derivative of the signal.
Respuestas (0)
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!