Kernel Density Estimation - Find the pdf and perform integration and derivative on this function

5 ビュー (過去 30 日間)
Tam Ho
Tam Ho 2018 年 1 月 2 日
編集済み: Tam Ho 2018 年 1 月 11 日
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 件のコメント
Christoph
Christoph 2018 年 1 月 11 日
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.
Tam Ho
Tam Ho 2018 年 1 月 11 日
編集済み: Tam Ho 2018 年 1 月 11 日
How to " use traditional signal processing approach, smooth the data and use a functions such as findpeaks on a numerical derivative of the signal." ? Can you give an example please?
Essentially the analysis procedure requires finding the pdf of the data and perform derivation on that.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by