How can I improve the accuracy of cumtrapz
7 次查看(过去 30 天)
显示 更早的评论
I need to find the CDF of a non standard probability distribution function (pdf). So I run the integral using cumtrapz then I got the vector = CDF. My code works, however the output is very poor regarding accuracy. I also use the function "integral" which is very accurate but the output of that function is a scalar. Is there any way to get a precise vector as an output?
I use the Weibull distribution JUST FOR testing the accuracy of cumtrapz.
This is my code
%test for finding the cdf of the variable YBL6 which follows the Weibull distribution theta = 2.10604; tau = 1.21248; Z = (YBL6./theta).^tau; %YBL6 is a vector of losses, which is not linear so I can't use x:0:dx:10 c = exp(-(Z)); Wpdf = (tau./YBL6).*Z.*c; Wcdf = cumtrapz(YBL6,Wpdf); % the result is a vector, which shows at the right end point the value=0.99668259 (no accurate)
% test 2, this code returns the maximum value of the CDF, % integral reports the final result of integration at the right endpoint=b % which is ok BUT the code doesn't produce a vector theta = 2.10604; tau = 1.21248; a = 0; b = max(YBL6); Wpdf = @(YBL6,theta,tau)((tau./YBL6).*((YBL6./theta).^tau).*exp(-((YBL6./theta).^tau))); % a function handle cdf = integral(@(YBL6)Wpdf(YBL6,theta,tau),a,b,'ArrayValued',true,'AbsTol',1e-12,'RelTol',1e-10); % the result is a scalar, which shows just the right end point the value=0.99668259 (very accurate)
2 个评论
dpb
2014-4-4
...value=0.99668259 (no accurate)...
followed by
...value=0.99668259 (very accurate)...
Look identical to me...???
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Function Creation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!