NAG Library Function Document nag_rand_bivariate_copula_frank (g05rfc)

Similar documents
NAG Library Function Document nag_rand_copula_clayton (g05rhc)

NAG Library Function Document nag_rand_2_way_table (g05pzc)

NAG Library Function Document nag_rand_copula_normal (g05rdc)

NAG Library Function Document nag_rand_arma (g05phc)

NAG Library Function Document nag_rngs_copula_students_t (g05rbc)

NAG Library Function Document nag_rgsn_matrix_multi_normal (g05lyc)

NAG Library Function Document nag_2_sample_ks_test (g08cdc)

NAG Library Routine Document G05REF.1

NAG Library Function Document nag_dtr_load (f16qgc)

NAG Library Routine Document G05RGF.1

NAG Library Function Document nag_dtrmv (f16pfc)

NAG Library Function Document nag_asian_geom_price (s30sac)

NAG Library Function Document nag_rngs_varma_time_series (g05pcc)

NAG Library Function Document nag_dgetri (f07ajc)

NAG Library Function Document nag_all_regsn (g02eac)

NAG Library Function Document nag_dsymv (f16pcc)

NAG C Library Function Document nag_binary_factor_service (g11sbc)

NAG Library Function Document nag_5d_shep_eval (e01tnc)

NAG Library Function Document nag_4d_shep_eval (e01tlc)

NAG Library Function Document nag_nd_shep_eval (e01znc)

NAG Library Function Document nag_real_sym_posdef_tridiag_lin_solve (f04bgc)

NAG Library Function Document nag_dgglse (f08zac)

NAG Library Function Document nag_mv_distance_mat (g03eac)

NAG Library Function Document nag_zhpr2 (f16ssc)

NAG Library Function Document nag_chain_sort (m01cuc)

NAG Library Function Document nag_ztbcon (f07vuc)

NAG Library Function Document nag_herm_posdef_tridiag_lin_solve (f04cgc)

NAG Library Function Document nag_prob_lin_non_central_chi_sq (g01jcc)

NAG Library Function Document nag_quasi_init_scrambled (g05ync)

NAG Library Function Document nag_dtrsyl (f08qhc)

NAG Library Function Document nag_complex_gen_lin_solve (f04cac)

NAG Library Function Document nag_2_sample_ks_test (g08cdc)

NAG Library Function Document nag_asian_geom_greeks (s30sbc)

NAG Library Function Document nag_1d_cheb_intg (e02ajc)

NAG Library Function Document nag_wav_2d_coeff_ins (c09ezc)

NAG Library Function Document nag_dpbtrf (f07hdc)

NAG Library Function Document nag_bsm_greeks (s30abc)

NAG Library Function Document nag_dsytrf (f07mdc)

NAG Library Function Document nag_mv_ordinal_multidimscale (g03fcc)

NAG Library Function Document nag_kruskal_wallis_test (g08afc)

NAG Library Function Document nag_complex_tridiag_lin_solve (f04ccc)

NAG Library Function Document nag_dtpttr (f01vcc)

NAG C Library Function Document nag_rngs_varma_time_series (g05pcc)

NAG C Library Function Document nag_dgemv (f16pac)

NAG Library Function Document nag_real_gen_matrix_exp (f01ecc)

NAG Library Function Document nag_corr_cov (g02bxc)

NAG Library Function Document nag_superlu_diagnostic_lu (f11mmc)

NAG Library Function Document nag_real_cholesky_skyline_solve (f04mcc)

NAG Library Function Document nag_zero_cont_func_brent_rcomm (c05azc)

NAG C Library Function Document nag_zgemv (f16sac)

NAG Library Function Document nag_1d_cheb_fit_constr (e02agc)

NAG Library Function Document nag_dspr (f16pqc)

NAG Library Function Document nag_dger (f16pmc)

NAG Library Function Document nag_dtrttf (f01vec)

NAG C Library Function Document nag_zhpmv (f16sec)

NAG Library Function Document nag_robust_m_corr_user_fn_no_derr (g02hmc)

NAG Library Function Document nag_robust_m_corr_user_fn (g02hlc)

NAG Library Function Document nag_mv_discrim (g03dac)

NAG Library Function Document nag_zero_nonlin_eqns_deriv_1 (c05ubc)

NAG Library Function Document nag_dtfttp (f01vlc)

NAG Library Function Document nag_bsm_price (s30aac)

NAG C Library Function Document nag_zhemv (f16scc)

NAG Library Function Document nag_zpbequ (f07htc)

NAG C Library Function Document nag_linf_fit (e02gcc)

NAG Library Function Document nag_tsa_multi_part_lag_corr (g13dnc)

NAG C Library Function Document nag_zger (f16smc)

NAG Library Function Document nag_dtpsv (f16plc)

NAG Library Function Document nag_mesh2d_inc (d06aac)

NAG Library Function Document nag_ztfttp (f01vmc)

NAG Library Function Document nag_ztrttf (f01vfc)

NAG Library Function Document nag_mv_cluster_indicator (g03ejc)

NAG Library Function Document nag_zsymv (f16tac)

NAG Library Function Document nag_dstev (f08jac)

NAG Library Function Document nag_partial_corr (g02byc)

NAG C Library Function Document nag_dgbmv (f16pbc)

NAG Library Function Document nag_dgb_norm (f16rbc)

NAG C Library Function Document nag_zsytri (f07nwc)

NAG Library Function Document nag_zgelsy (f08bnc)

NAG Library Function Document nag_summary_stats_onevar_combine (g01auc)

NAG C Library Function Document nag_zhbmv (f16sdc)

NAG Library Function Document nag_dummy_vars (g04eac)

NAG C Library Function Document nag_dsbmv (f16pdc)

NAG Library Function Document nag_opt_one_var_deriv (e04bbc)

NAG Library Function Document nag_zhpev (f08gnc)

NAG Library Function Document nag_dgetrf (f07adc)

NAG Library Function Document nag_smooth_spline_fit (g10abc)

NAG Library Function Document nag_3d_shep_interp (e01tgc)

NAG Library Function Document nag_2d_spline_eval (e02dec)

NAG Library Function Document nag_zhpr2 (f16ssc)

NAG Library Function Document nag_matop_complex_gen_matrix_cond_sqrt (f01kdc)

NAG Library Function Document. nag_matop_real_gen_matrix_cond_num

NAG Library Function Document. nag_matop_complex_gen_matrix_cond_num

NAG Library Function Document nag_friedman_test (g08aec)

NAG Library Function Document nag_dgttrs (f07cec)

NAG C Library Function Document nag_surviv_risk_sets (g12zac)

NAG C Library Function Document nag_zspcon (f07quc)

NAG Library Function Document nag_dgelsd (f08kcc)

NAG C Library Function Document nag_cp_stat (g02ecc)

NAG Library Function Document nag_dgbmv (f16pbc)

NAG C Library Function Document nag_rank_regsn (g08rac)

Transcription:

1 Purpose NAG Library Function Document nag_rand_bivariate_copula_frank () nag_rand_bivariate_copula_frank () generates pseudorandom uniform bivariates with joint distribution of a Frank Archimedean copula. 2 Specification #include <nag.h> #include <nagg05.h> void nag_rand_bivariate_copula_frank (Nag_OrderType order, Integer state[], double theta, Integer n, double x[], Integer ldx, Integer tdx, NagError *fail) 3 Description Generates pseudorandom uniform bivariates fu 1 ;u 2 g 2 ½0; 1Š 2 whose joint distribution is the Frank Archimedean copula C with parameter, given by 2 3 C ¼ 1 e u 1 1 e u 2 1 ln 4 1 þ 5, e 2 ð 1; 1Þnfg 0 1 with the special cases: C 1 ¼ maxðu 1 þ u 2 1; 0Þ, the Frechet Hoeffding lower-bound; C 0 ¼ u 1 u 2, the product copula; C 1 ¼ minðu 1 ;u 2 Þ, the Frechet Hoeffding upper-bound. The generation method uses conditional sampling. One of the initialization routines nag_rand_init_repeatable (g05kfc) (for a repeatable sequence if computed sequentially) or nag_rand_init_nonrepeatable (g05kgc) (for a non-repeatable sequence) must be called prior to the first call to nag_rand_bivariate_copula_frank (). 4 References Nelsen R B (2006) An Introduction to Copulas (2nd Edition) Springer Series in Statistics 5 Arguments 1: order Nag_OrderType Input On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., rowmajor ordering or column-major ordering. C language defined storage is specified by order ¼ Nag_RowMajor. See Section 3.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument. Constraint: order ¼ Nag_RowMajor or Nag_ColMajor. 2: state½lstateš Integer Communication Array Note: lstate ¼ lstate, the dimension of state as supplied to the initialization function nag_rand_init_repeatable (g05kfc) or nag_rand_init_nonrepeatable (g05kgc). On entry: contains information on the selected base generator and its current state..1

NAG Library Manual On exit: contains updated information on the state of the generator. 3: theta double Input On entry:, the copula parameter. 4: n Integer Input On entry: n, the number of bivariates to generate. Constraint: n 0. 5: x½ldx tdxš double Output Note: where Xði; jþ appears in this document, it refers to the array element x½ðj 1Þldx þ i 1Š when order ¼ Nag_ColMajor; x½ði 1Þtdx þ j 1Š when order ¼ Nag_RowMajor. On exit: the n bivariate uniforms with joint distribution described by C, with Xði; jþ holding the ith value for the jth dimension. 6: ldx Integer Input On entry: the first dimension of the array x as declared in the function from which nag_rand_bivariate_copula_frank () is called. Constraints: if order ¼ Nag_ColMajor, ldx n; if order ¼ Nag_RowMajor, ldx 2. 7: tdx Integer Input On entry: the second dimension of the array x as declared in the function from which nag_rand_bivariate_copula_frank () is called. Constraints: if order ¼ Nag_ColMajor, tdx 2; if order ¼ Nag_RowMajor, tdx n. 8: fail NagError * Input/Output The NAG error argument (see Section 3.6 in the Essential Introduction). 6 Error Indicators and Warnings NE_BAD_PARAM On entry, argument NE_INT On entry, n ¼ hvaluei. Constraint: n 0. NE_INT_2 On entry, ldx must be at least On entry, tdx must be at least hvaluei had an illegal value. hvaluei: ldx ¼ hvaluei. hvaluei: tdx ¼ hvaluei. NE_INTERNAL_ERROR An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance..2

NE_INVALID_STATE On entry, corrupt state parameter. 7 Accuracy Not applicable. 8 Further Comments In practice, the need for numerical stability restricts the range of such that: if <ln s, the function returns pseudorandom uniform variates with C 1 joint distribution; if jj< 1:0 10 6, the function returns pseudorandom uniform variates with C 0 joint distribution; if >ln, the function returns pseudorandom uniform variates with C 1 joint distribution; where s is the implementation-specific safe-range parameter, the value of which is returned by nag_real_safe_small_number (X02AMC); and is the machine precision returned by nag_machine_precision (X02AJC). 9 Example This example generates thirteen variates for copula C 12:0. 9.1 Program Text /* nag_rand_bivariate_copula_frank () Example Program. * * Copyright 2009, Numerical Algorithms Group. * * Mark 9, 2009. */ /* Pre-processor includes */ #include <stdio.h> #include <math.h> #include <nag.h> #include <nagx04.h> #include <nag_stdlib.h> #include <nagg05.h> #define X(I, J) x[order == Nag_ColMajor?((J-1)*pdx + I-1):((I-1)*pdx + J-1)] int main(int argc, char *argv[]) FILE *fpout = 0; /* Integer scalar and array declarations */ Integer exit_status = 0; Integer i, lstate, pdx, sdx; Integer *state = 0; /* Double scalar and array declarations */ double *x = 0; /* NAG structures */ NagError fail; /* Use row major order */ Nag_OrderType order = Nag_RowMajor; /* Set the number of variates */ Integer n = 13; /* Choose the base generator */ Nag_BaseRNG genid = Nag_Basic;.3

NAG Library Manual Integer subid = 0; /* Set the seed */ Integer seed[] = 1762543 ; Integer lseed = 1; /* Set the theta parameter value */ double theta = -12.0e0; /* Initialise the error structure */ INIT_FAIL(fail); /* Check for command-line IO options */ fpout = nag_example_file_io(argc, argv, "-results", NULL); fprintf(fpout, "nag_rand_bivariate_copula_frank () " "Example Program Results\n\n"); /* Get the length of the state array */ lstate = -1; nag_rand_init_repeatable(genid, subid, seed, lseed, state, &lstate, &fail); fprintf(fpout, "Error from nag_rand_init_repeatable (g05kfc).\n%s\n", fail.message); /* Set matrix size and principal dimension according to storage order */ pdx = (order == Nag_ColMajor)?n:2; sdx = (order == Nag_ColMajor)?2:n; /* Allocate arrays */ if (!(x = NAG_ALLOC((pdx*sdx), double))!(state = NAG_ALLOC(lstate, Integer))) fprintf(fpout, "Allocation failure\n"); exit_status = -1; /* Initialise the generator to a repeatable sequence */ nag_rand_init_repeatable(genid, subid, seed, lseed, state, &lstate, &fail); fprintf(fpout, "Error from nag_rand_init_repeatable (g05kfc).\n%s\n", fail.message); /* Generate variates */ nag_rand_bivariate_copula_frank(order, state, theta, n, x, pdx, sdx, &fail); fprintf(fpout, "Error from nag_rand_bivariate_copula_frank ().\n" "%s\n", fail.message); /* Display the results */ fprintf(fpout, "Uniform variates with copula joint distrbution\n"); for (i = 1; i <= n; i++) fprintf(fpout, " %9.6f %9.6f\n", X(i, 1), X(i, 2)); END:.4

if (fpout!= stdout) fclose(fpout); if (x) NAG_FREE(x); if (state) NAG_FREE(state); return exit_status; 9.2 Program Data None. 9.3 Program Results nag_rand_bivariate_copula_frank () Example Program Results Uniform variates with copula joint distrbution 0.636373 0.141124 0.106480 0.896697 0.746035 0.184315 0.798270 0.125439 0.104592 0.998172 0.492451 0.690103 0.384260 0.625047 0.787070 0.165409 0.498187 0.529766 0.671703 0.290232 0.050537 0.955405 0.258030 0.818964 0.623806 0.301387.5 (last)