ncx2mixtcdf

ncx2mixtcdf computes cumulative distribution function of a linear combination of non-central chi-square +N(0,s)

Syntax

  • qfval=ncx2mixtcdf(c,n,lb,nc)example
  • qfval=ncx2mixtcdf(c,n,lb,nc,Name,Value)example
  • [qfval,varargout]=ncx2mixtcdf(___)example

Description

Given random variable $Q$ defined as \[ Q = \lambda_1 \chi^2_1 + \lambda_2 \chi_2 + ... + \lambda_k \chi^2_k +\sigma Z \]

where $\chi^2_1, ..., \chi^2_k$ are $k$ non central chi squared random variables, with non centrality parameters $\delta=(\delta_1, ..., \delta_k)$ and degrees of freedom $df=(df_1, ..., df_k)$.

and $Z$ is a standard normal random variable, the purpose of this routine is to compute $F_Q(x | df, delta) = P(Q < x| df, delta)$ , that is the cdf of $Q$ evaluated at $x$.

example

qfval =ncx2mixtcdf(c, n, lb, nc) cdf of two chi squared rv.

example

qfval =ncx2mixtcdf(c, n, lb, nc, Name, Value) cdf of the sum of two non central chi2.

example

[qfval, varargout] =ncx2mixtcdf(___) Test tolerance.

Examples

expand all

  • cdf of two chi squared rv.
  • Evaluate the cdf of the sum of two chi2 r.v. with degrees of freedom 5 and 4 and coefficients of the linear combination 2 and 3 and non centrality parameters 1 and 6

    x=35;
    df=[5;4];
    lb=[2;3];
    nc=[1;6];
    [out]=ncx2mixtcdf(x,df,lb,nc);

  • cdf of the sum of two non central chi2.
  • Evaluate the cdf of the sum of two chi2 r.v. with degrees of freedom 5 and 4 and coefficients of the linear combination 2 and 3 and non centrality parameters 1 and 6. Evaluate the cdf in a series of values of x and plot the output

    df=[5;4];
    lb=[2;3];
    nc=[1;6];
    xx=0:1:100;
    cdfnc=zeros(length(xx),1);
    ij=1;
    for x=xx
    [out]=ncx2mixtcdf(x,df,lb,nc);
    cdfnc(ij)=out;
    ij=ij+1;
    end
    plot(xx',cdfnc)
    xlabel('x')
    ylabel('cdf of the mixture of non central X2')

  • Test tolerance.
  • Example which tests the results using different tolerances and a different number of integration terms

    df=[1;1];
    lb=[-0.965785811006555;-0.681122597105154];
    nc=[0.2;0.3];
    x=-2.386488889335108;
    [out]=ncx2mixtcdf(x,df,lb,nc);
    disp('Value of cdf using default number of integration terms and default tolerance')
    disp(out)
    disp('-------------------------')
    tol=1e-06;
    [out]=ncx2mixtcdf(x,df,lb,nc,'tol',tol);
    disp(['Value of cdf using tol =' num2str(tol) ' and default integration terms'])
    disp(out)
    disp('-------------------------')
    lim=1000000;
    [out]=ncx2mixtcdf(x,df,lb,nc,'lim',lim);
    disp(['Value of cdf using numb. integration terms =' num2str(lim) ' and default tolerance'])
    disp(out)
    disp('-------------------------')
    lim=100000000;
    tol=1e-13;
    disp(['Value of cdf using numb. integration terms =' num2str(lim) ' and tolerance=' num2str(tol)])
    disp('In this last case it takes some seconds')
    [out]=ncx2mixtcdf(x,df,lb,nc, 'lim',lim, 'tol',tol);
    disp(out)

    Input Arguments

    expand all

    c — value for which cdf has to be computed. Scalar.

    Value at which the cdf must be evaluated

    Data Types: single| double

    n — degrees of freedom. Vector.

    Vector of length k containing the degrees of freedom of the k non central chi2 distributions

    Data Types: single| double

    lb — Coefficients of linear combination. Vector.

    Vector of length k containing the coefficients of the linear combinations of the k non central chi2 distributions

    Data Types: single| double

    nc — Non centrality parameters. Vector.

    Vector of length k containing the k non centrality parameters of the k non central chi2 distributions

    Data Types: single| double

    Name-Value Pair Arguments

    Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

    Example: 'lim',100000 , 'sigma',1 , 'tol',1e-10

    lim —Number of intergration terms.scalar.

    Scalar which defines maximum number of integration terms.

    The default value of lim is 10000 Remark: The user should only give the input arguments that have to change their default value.

    The name of the input arguments needs to be followed by their value. The order of the input arguments is of no importance.

    Example: 'lim',100000

    Data Types: double

    sigma —standard deviation of N(0,1).scalar.

    Coefficient associated with standard deviation of the standard normal distribution which can be added to the linear combination of non central chi2 distributions The default value of sigma is 0

    Example: 'sigma',1

    Data Types: double

    tol —Tolerance.scalar.

    Scalar which controls the tolerance. The default value of tolerance is 1e-09

    Example: 'tol',1e-10

    Data Types: double

    Output Arguments

    expand all

    qfval —Value of cdf. Scalar

    $qfval=F_Q(x | df, delta, sigma)$ is the value of the cdf of the mixture evaluated at x

    varargout —FULL STOP MISSING IN THE OUTPUT DESCRIPTION tracert : vector of length 7

    Tracert(1) = absolute sum tracert(2) = total number of integration terms tracert(3) = number of integrations tracert(4) = integration interval in final integration tracert(5) = truncation point in initial integration tracert(6) = standard deviation of initial convergence factor tracert(7) = number of iterations needed to locate integration parameters ifault : scalar which informs about output of the procedure ifault=0 everything went OK ifault=1 required accuracy not achieved ifault=2 round-off error possibly significant ifault=3 invalid parameters (df or non centr parameters smaller than 0 or lmin=lmax=sigma=0) ifault=4 unable to locate integration parameters

    References

    Davies, R. (1973), Numerical inversion of a characteristic function, "Biometrika", Vol. 60, pp. 415-417.

    Davies, R. (1980), The distribution of a linear combination of chi-square random variables, "Applied Statistics", Vol. 29, pp. 323-333.

    See Also

    |

    This page has been automatically generated by our routine publishFS