Integrate kernel probability distribution function
6 ビュー (過去 30 日間)
古いコメントを表示
Dear MatLab comunity,
I have a distribution of dihedral angles over a number of frames from a simulation. (attached is the data file)
M2OH6 = load('OH6p.txt');
y6 = M2OH6(:,2);
nbins = 100;
rng('default')
[f3,y6i] = ksdensity(y6);
plot(y6i,f3,'Color','r','Linewidth',1)
xlabel('\theta (deg)');
ylabel('P(\theta) (deg^{-1})');
xticks(-360:60:360);
yticks(0:0.01:0.045);
axis([-360 360 0 0.045]);
pbaspect([1 1 1]);
So I need to know what is the percentage of the states falling in the range between let's say 0:120 degrees (theta), 120:180 degrees and 180:-120.
In such case I was thinking that maybe I should integrate the kernel density function in such ranges but I'm not sure how to do it and obviously I'm a very beginner in MatLab.
Is there anybody who could suggest me a way?
Thanks in advance,
Alex
0 件のコメント
回答 (2 件)
Peng Li
2020 年 8 月 5 日
trapz is a function that deals with numerical integration. Check the above link for details.
0 件のコメント
Jeff Miller
2020 年 8 月 5 日
If you just want to know the percentages in various ranges, it seems easier to tabulate the scores directly than to mess about with ksdensity. What about just something like:
M2OH6 = load('OH6p.txt');
y6 = M2OH6(:,2);
binEdges = [-180 -120 0 120 180]; % set the boundaries to isolate the bin ranges you are interested in
counts = histcounts(y6,binEdges); % count the number of scores in each range
pcts = counts / length(y6)*100 % convert to percentages
the first pcts value will be the % between -180 and -120, the second between -120 and 0, etc. Obviously you can set the bin edges whereever you want them.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!