How to compute uniform cumulative distribution functions without an existing unifcdf (error UndefinedFunction)?
1 次查看(过去 30 天)
显示 更早的评论
For a sensitivity analysis, the calculation of the uniform-cdf is required (within a m-script).
In Matlab R2012a (Student-Version) the calculation of the uniform cumulative distribution function runs with unifcdf without problems.
If I move the entire calculation to a HPC (cluster -> compiling -> standalone version -> run standalone version) due to computer performance, the following error message appears:
Error using feval
Undefined function 'unifcdf' for input arguments of type 'double'.
Error in AAT_sampling_extend (line 108)
Error in extended_sample (line 66)
MATLAB:UndefinedFunction
The Matalb version R2017a is installed on this cluster. The statistics toolbox is available (and both functions feval and unifcdf).
I've tried the following:
I have written a function unifcdf within a m-file and provided it MATLAB. However, the same error message appeared.
How can I solve this problem?
0 个评论
回答(1 个)
John D'Errico
2017-8-5
This seems a bit silly. The CDF of a uniform distribution is a straight line, running from the min to the max of the data. WTP?
3 个评论
John D'Errico
2017-8-6
编辑:John D'Errico
2017-8-6
Surely you are not telling me that you cannot write a function called unifcdf that computes and uses the necessary straight line?
You must know the limits of the uniform distribution, else it is undefined, and you could never have used unifcdf in the first place. So the straight line CDF is trivial to write, and thus use. WTP?
Lets see, a uniform distribution has a CONSTANT PDF on the domain [a,b]. Therefore we know that
P(x) = 1/(b-a), for x in the interval [a,b]
Next, we need to integrate a constant function over that interval. EUREKA! The CDF is a line segment on the support of the PDF! The CDF is zero at x==a, and zero below that point. At and above x==b, the CDF is 1, and it is linear between those points. Start like this:
function p = unifcdf(x,a,b)
%Compute p here, as a function of x, a, b
p = zeros(size(x));
p(x>b) = 1;
...
That gets you started. Now you need to fill in the line part, for x>a & x<b.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!