-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgx2cdf_ray.m
33 lines (26 loc) · 1.08 KB
/
gx2cdf_ray.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function [p,p_err]=gx2cdf_ray(x,w,k,lambda,s,m,varargin)
parser=inputParser;
parser.KeepUnmatched=true;
addRequired(parser,'x',@(x) isreal(x));
addRequired(parser,'w',@(x) isreal(x));
addRequired(parser,'k',@(x) isreal(x));
addRequired(parser,'lambda',@(x) isreal(x));
addRequired(parser,'s',@(x) isreal(x) && isscalar(x));
addRequired(parser,'m',@(x) isreal(x) && isscalar(x));
addOptional(parser,'side','lower',@(x) strcmpi(x,'lower') || strcmpi(x,'upper') );
parse(parser,x,w,k,lambda,s,m,varargin{:});
side=parser.Results.side;
y=x(:); % flatten input array x into a column vector of levels y
% find standard quadratic form corresponding to the gx2:
quad=gx2_to_norm_quad_params(w,k,lambda,s,m);
dim=numel(quad.q1);
mu=zeros(dim,1);
v=eye(dim);
% integrate with 'lower' for lower side.
[p,p_err]=int_norm_ray(mu,v,quad,varargin{:},'side',side,'fun_level',y);
% reshape flattened output arrays to shape of input x
p=reshape(p,size(x));
if ~isempty(p_err)
p_err=reshape(p_err,size(x));
end
end