Home
Package `Runuran`
Contents
1. Author s Josef Leydold and Kemal Dingec lt unuran statmath wu ac at gt References Grigelionis B 1999 Processes of Meixner type Lithuanian Mathematical Journal Vol 39 p 33 41 Schoutens W 2001 The Meixner Processes in Finance Eurandom Report 2001 002 Eurandom Eindhoven See Also unuran cont Examples Create distribution object for meixner distribution distr lt udmeixner alpha 0 0298 beta 0 1271 delta 0 5729 mu 0 0011 Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 58 udnbinom udnbinom UNU RAN object for Negative Binomial distribution Description Create UNU RAN object for a Negative Binomial distribution with parameters size and prob Distribution Negative Binomial Usage udnbinom size prob lb ub Inf Arguments size target for number of successful trials or dispersion parameter the shape param eter of the gamma mixing distribution Must be strictly positive prob probability of success in each trial lt prob lt 1 lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Negative Binomial distribution with size n and prob p has density pla Ap for x 0 1 2 gt 0 and 0 lt p lt 1 This represents the number of failures which occur in a sequence of Bernoulli trials before a target number of succe
2. Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg unuran distr class 81 See Also unuran diser unuran new unuran Examples Create a distribution object with given PV and mode mypv lt dbinom 0 100 100 0 3 distr lt new unuran discr pv mypv 1b 0 mode 30 Create discrete distribution with given probability vector the PV need not be normalized pv lt c 1 2 1 5 0 3 1 2 dpv lt new unuran discr pv pv lb 1 Create discrete distribution with given PMF pmf lt function x dbinom x 100 0 3 dpmf lt new unuran discr pmf pmf l1b 0 ub 100 unuran distr class Virtual class unuran distr Description The virtual class unuran distr provides an interface to UNU RAN objects for distributions The following classes extend this class class unuran cont for univariate continuous distributions see unuran cont class unuran discr for discrete distributions see unuran discr class unuran cmv for multivariate continuous distributions see unuran cmv Advanced Distribution Object Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References J Leydold and W H ormann 2000 2007 UNU RAN User Manual see http statmath wu ac at unuran Se
3. Usage ug unr U Arguments unr a unuran object that implements an inversion menthod U vector of probabilities Details The routine evaluates the quantiles inverse CDF for a given vector of probabilities approxi mately It requires a unuran object that implements an inversion method Currently these are e HINV e NINV e PINV for continuous distributions and 90 uq e DGT for discrete distributions uq returns the left boundary of the domain of the distribution if argument U is less than or equal to and the right boundary if U is greater than or equal to 1 Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also unuran unuran new Examples Compute quantiles of normal distribution using method PINV gen lt pinv new pdf dnorm lb Inf ub Inf uq gen seq 0 1 0 05 Compute quantiles of user defined distribution using method PINV pdf lt function x exp x gen lt pinv new pdf pdf 1b 0 ub Inf uresolution 1 e 12 uq gen seq 1 0 5 Compute quantiles of binomial distribution using method DGT gen lt dgt new pv dbinom 0 1000 1000 0 4 from 0 uq gen seq 1 0 5 Compute quantiles of normal distribution using method HINV using advanced inte
4. 2 Object obj is a generator object that implements method PINV In this case an approximate value for the CDF is returned The approximation error is about one tenth of the requested uresolution for method PINV 3 Neither the CDF nor its approximation is available in object obj NA is returned and a warning is thrown Note The generator object must not be packed see unuran packed Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also unuran cont unuran discr unuran pinv new uq 89 Examples Create an UNU RAN distribution object for standard Gaussian and evaluate distribution function for some points distr lt udnorm up distr 1 5 up distr 3 3 Create an UNU RAN generator object for standard Gaussian and evaluate distribution function of underyling distribution unr lt tdrd new udnorm up unr 1 5 up unr 3 3 Create an UNU RAN generator object that does not contain the CDF but implements method PINV unr lt pinv new pdf function x exp x lb 0 ub Inf up unr 5 uq Quantile function for unuran object Description Evaluates quantile of distribution approximately using a unuran object that implements an inversion method Universal Quantile Function
5. Create distribution object for Gumbel distribution distr lt udgumbel gt Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udhyper 47 udhyper UNU RAN object for Hypergeometric distribution Description Create UNU RAN object for a Hypergeometric distribution with parameters m n and k Distribution Hypergeometric Usage udhyper m n k lb max k n ub min k m Arguments m the number of white balls in the urn n the number of black balls in the urn k the number of balls drawn from the urn lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Hypergeometric distribution is used for sampling without replacement The density of this distribution with parameters m n and k named Np N Np and n respectively in the reference below is given by a NL 00 The domain of the distribution can be truncated to the interval 1b ub forx 0 k Value An object of class unuran discr Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and A W Kemp 1992 Univariate Discrete Distributions 2nd edition John Wiley 8 Sons Inc New York Chap 6 p 237 48 udhyperbolic Examples Create distribution object for Hypergeometric distribution dist lt udhyper m 15 n 5 k 7 Generate
6. it can be any multiple of a density function The center is used as starting point of the Hit and Run algorithm It is thus important that the center is contained in the interior of the domain Alternatively one could provide the location of the mode However this requires its exact position whereas center allows any point in the typical region of the distribution hitro new 15 If the mode is given then it is used to obtain an upper bound on the pdf and thus its location should be given sufficiently accurate The HITRO algorithm is a MCMC samplers and thus it does not produce a sequence of indepen dent variates The drawn sample follows the target distribution only approximately The dependence between consecutive vectors can be decreased when only a subsequence is returned and the other elements are erased This is called thinning of the Markov chain and can be controlled by the thinning factor A thinning factor k means that only every k th element is returned Markov chains also depend on the chosen starting point i e the center in this implementation of the algorithm This dependence can be decreased by erasing the first part of the chain This is called the burn in of the Markov chain and its length is controlled by the argument burnin Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References R Karawatzki J Leydold and K P otzelberger 2005 Automatic Ma
7. 1 The generation algorithm uses transformed density rejection TDR The parameters 1b and ub can be used to generate variates from the Planck distribution truncated to the interval 1b ub 122 urpois Note This function is wrapper for the UNU RAN class in R Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation and unuran for the UNU RAN class Examples Create a sample of size 1000 x lt urplanck n 1000 a 2 urpois UNU RAN Poisson random variate generator Description UNU RAN random variate generator for the Poisson distribution with parameter lambda It also allows sampling from the truncated distribution Special Generator Sampling Function Poisson Usage urpois n lambda lb ub Inf Arguments n size of required sample lambda non negative mean lb lower bound of truncated distribution ub upper bound of truncated distribution urpowerexp 123 Details The Poisson distribution has density forg 0 1 2 00 4 The generation algorithm uses guide table based inversion when the tails are not too heavy and method DART otherwise The parameters 1b and ub can be used to generate variates from the Poisson distribution trunc
8. 2 a e a 22 Runuran special generators o oo a 24 STOUNCW i ci koee EEA i a aa E O GE OHA e e ea e 26 ENE WE A id a al 27 Wa oss eee chy e a Be E ae AR a a ts da a ee Be 29 vUbeta z ib a de en ee ae eect te de hee dra a 31 UdbINGM 5 25 ei a AAA A A A ARA a da 32 UACAUC N sn a e ek a ee oe See Boe dd 33 A A ee ee eee 34 dehisd fs twa ea SD wal Bota EE a BR a ae ab Go ale eo Gael 36 UdP cate sie ea cae ai bee eS a a A 37 A ee des Gece Se Ge oot cas cee acs eve wert a oe epee Oe ee te ee or tn 38 UGITEGHEL a ear sk ote ho ee A ae GAR ae eA OG ae Ge ats 39 e A haus been b bade we ee ee bag am a8 40 dggom eG gb ee ee ey NR ee Se ee Be eed bo 41 USO Po vii aw e Ma wee Roe ti a a e A a dr 42 LTI ea a a a OR AU A E AR A we eee Be 44 dg mbel Vice s be ER ee bee he be 45 Why Per cedi den we Se Eee DE BH REB AD Owe o ORES Se AEE SAS 47 udbyperbolic sas p og dr Bae ee Sd bo gd ee Ee ee 48 WMS os eee ke ate eR a eee hE eee bed HS 49 Udlaplace e riada ee ee Bob A Ss Bae PES e Ae che AN 50 Po 4 5 6 646 beat eed Sb eee eee edn BEER ES 31 Udlogaritbmic os s op a o e a e e RR a Ba a iE a ee ee 33 UGlOSIS e 2 weet aa eed As A A dd ss 54 Pe AEREA 55 MOMCIX AA EA II 56 UdnbINOM e e aa te Ee O a BA Da Be Ai e a ew 58 UJAO kano ke a E A dd dd 59 UIAPATELO si ec RE AEE RA Re E ee E G A 60 UAPOLS pair ais e a ls A A AA e whi eae bere 61 OPOWETEXD coimas os a a Res a ee a 63 UdrayleiP es vs rr E UR A A 64 udslash 4 go
9. Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also unuran cmv unuran new unuran Examples Get a distribution object with given pdf and mode mvpdf lt function x exp sum x 2 mvd lt unuran cmv new dim 2 pdf mvpdf mode c 0 0 Restrict domain to rectangle 0 1 x 0 1 and set mode to 0 0 mvpdf lt function x exp sum x 2 mvd lt unuran cmv new dim 2 pdf mvpdf 1l c 0 ur c 1 1 mode c 0 0 unuran cont class Class unuran cont for Continuous Distribution Description Class unuran cont provides an interface to UNU RAN objects for continuous distributions The interface might be changed in future releases Do not use unnamed arguments Advanced Continuous Distribution Object Details Create a new instance of a unuran cont object using new unuran cont cdf NULL pdf NULL dpdf NULL islog FALSE 1b NA ub NA mode NA cent cdf cumulative distribution function R function pdf probability density function R function dpdf derivative of the pdf R function islog whether the given cdf and pdf are given by their logarithms the dpdf is then the derivative of the logarithm boolean unuran cont new 75 Ib lower bound of domain use Inf if unbounded from left numeric ub upper bound of domain use Inf if unbounded from right numeric mode mode of distribution numeric
10. See Also runif and Random seed about random number generation and unuran for the UNU RAN class Examples Create a sample of size 1000 x lt urgig n 1000 lambda 2 omega 3 urhyper 109 urhyper UNU RAN Hypergeometric random variate generator Description UNU RAN random variate generator for the Hypergeometric distribution It also allows sampling from the truncated distribution Special Generator Sampling Function Hypergeometric Usage urhyper nn m n k lb max k n ub min k m Arguments nn number of observations m the number of white balls in the urn n the number of black balls in the urn k the number of balls drawn from the urn lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Hypergeometric distribution is used for sampling without replacement The density of this distribution with parameters m n and k named Np N Np and n respectively in the reference below is given by e The generation algorithm uses guide table based inversion The parameters 1b and ub can be used to generate variates from the Hypergeometric distribution truncated to the interval 1b ub forx 0 k Note This function is a wrapper for the UNU RAN class in R Compared to rhyper urhyper is faster especially for larger sample sizes However in opposition to rhyper vector arguments are ignored i e only the first entry is used Author s Josef
11. UNU RAN random variate generator for the Generalized Inverse Gaussian Distribution with pa rameters lambda and omega It also allows sampling from the truncated distribution Special Generator Sampling Function GIG generalized inverse Gaussian Usage urgig n lambda omega lb 1 e 12 ub Inf 108 urgig Arguments n size of required sample lambda strictly positive shape parameter omega strictly positive shape parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Generalized Inverse Gaussian distribution with parameters lambda and omega w has a density proportional to f a 2 exp w 2 a 1 2 for z gt 0 A gt O0andw gt 0 The generation algorithm uses transformed density rejection TDR The parameters 1b and ub can be used to generate variates from the distribution truncated to the interval 1b ub The generation algorithm works for A gt 1 and w gt 0 and for A gt 0 and w gt 0 5 Note This function is wrapper for the UNU RAN class in R Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 15 p 284
12. center typical point center of distribution If not given the mode is used numeric area area below pdf used for computing normalization constants if required numeric name name of distribution string The user is responsible that the given informations are consistent It depends on the chosen method which information must be given are used Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References J Leydold and W H ormann 2000 2007 UNU RAN User Manual see http statmath wu ac at unuran See Also unuran cont new unuran new unuran Examples Create continuous distribution with given logPDF and its derivative pdf lt function x 5 x 2 dpdf lt function x x distr lt new unuran cont pdf pdf dpdf dpdf islog TRUE lb Inf ub Inf unuran cont new Create a UNU RAN continuous univariate distribution object Description Create a new UNU RAN object for a continuous univariate distribution The interface might be changed in future releases Do not use unnamed arguments Advanced Continuous Distribution Usage unuran cont new cdf NULL pdf NULL dpdf NULL islog FALSE lb NA ub NA mode NA center NA area NA name NA 76 unuran cont new Arguments cdf cumulative distribution function R function pdf probability density function R function dpdf derivative of the pdf R function islog whether the given cdf a
13. distribution Details The Log Normal distribution has density Fla e toate m 20 270 where u and o are the mean and standard deviation of the logarithm The generation algorithm uses fast numerical inversion The parameters 1b and ub can be used to generate variates from the Log Normal distribution truncated to the interval 1b ub Note This function is wrapper for the UNU RAN class in R Compared to rlnorm urlnorm is faster especially for larger sample sizes However in opposition to rlnorm vector arguments are ignored i e only the first entry is used Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation unuran for the UNU RAN class and rlnorm for the R built in generator Examples Create a sample of size 1000 x lt urlnorm n 1000 114 urlogarithmic urlogarithmic UNU RAN Logarithmic random variate generator Description UNU RAN random variate generator for the Logarithmic distribution with shape parameter shape It also allows sampling from the truncated distribution Special Generator Sampling Function Logarithmic Usage urlogarithmic n shape lb 1 ub Inf Arguments n size of required sample shape shape parameter Must be
14. lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udgamma UNU RAN object for Gamma distribution Description Create UNU RAN object for a Gamma distribution with parameters shape and scale Distribution Gamma Usage udgamma shape scale 1 1b 0 ub Inf Arguments shape strictly positive shape parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution udgeom 41 Details The Gamma distribution with parameters shape a and scale a has density e e o T a a lo7T 0 f x for x gt 0 a gt 0 and gt 0 Here T a is the function implemented by R s gamma and defined in its help The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 17 p 337 See Also unuran cont Examples Create distribution object for gamma distribution distr lt udgamma shape 4 Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udgeom UNU RAN object for Geometric distribution Descript
15. scale 1 lb Inf ub Inf Arguments n size of required sample location location parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution 96 urchi Details If location or scale are not specified they assume the default values of and 1 respectively The Cauchy distribution with location and scale s has density 1 1 z 1 Ha TS Ss The generation algorithm uses fast numerical inversion The parameters 1b and ub can be used to generate variates from the Cauchy distribution truncated to the interval 1b ub for all z Note This function is wrapper for the UNU RAN class in R Compared to rcauchy urcauchy is faster especially for larger sample sizes However in opposition to rcauchy vector arguments are ignored i e only the first entry is used Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation unuran for the UNU RAN class and rcauchy for the R built in generator Examples Create a sample of size 1000 x lt urcauchy n 1000 urchi UNU RAN Chi random variate generator Description UNU RAN random variate generator for the Chi X distribution with df d
16. scale 1 lb Inf ub Inf Arguments n size of required sample location location parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details If location or scale are omitted they assume the default values of and 1 respectively The Logistic distribution with location y and scale a has distribution function Fle 1 Teme and density 1 ele B o F z a 1 I elo 1 0 2 The generation algorithm uses inversion The parameters 1b and ub can be used to generate variates from the Logistic distribution truncated to the interval 1b ub 116 urlomax Note This function is a wrapper for the UNU RAN class in R Compared to rlogis urlogis is faster especially for larger sample sizes However in opposition to rlogis vector arguments are ignored i e only the first entry is used Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation unuran for the UNU RAN class and rlogis for the R built in generator Examples Create a sample of size 1000 x lt urlogis n 1000 urlomax UNU RAN Lomax random variate generator Description UNU RAN random variate generator for the Lomax
17. Create the UNU RAN generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 Compute some quantiles for Monte Carlo methods x lt uq gen 1 9 10 Analogous for half normal distribution distr lt udnorm 1b 0 ub Inf 24 Runuran special generators gen lt pinvd new distr x lt ur gen 100 x lt uq gen 1 9 10 Analogous for a generalized hyperbolic distribution distr lt udghyp lambda 1 0024 alpha 39 6 beta 4 14 delta 0 0118 mu 0 000158 gen lt pinvd new distr x lt ur gen 100 x lt uq gen 1 9 10 It is also possible to compute density or distribution functions However this might not work for all generator objects HH Density x lt ud gen 1 2 HH Cumulative distribution function x lt up gen 1 2 Runuran special generators Generators for distributions based on methods from the UNU RAN li brary Description Generators for particular distributions Their syntax is similar to the corresponding R built in func tions Details Runuran provides an interface to the UNU RAN library for universal non uniform random number generators This is a very flexible and powerful collection of sampling routines where the user first has to specify the target distribution and then has to choose an appropriate sampling method However we found that this approach is a little bit confusing for the b
18. Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt 110 urhyperbolic References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation unuran for the UNU RAN class and rhyper for the R built in generator Examples Create a sample of size 1000 x lt urhyper nn 20 m 15 n 5 k 7 urhyperbolic UNU RAN Hyperbolic random variate generator Description UNU RAN random variate generator for the Hyperbolic distribution with parameters shape and scale It also allows sampling from the truncated distribution Special Generator Sampling Function Hyperbolic Usage urhyperbolic n shape scale 1 lb Inf ub Inf Arguments n size of required sample shape strictly positive shape parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details If scale is omitted it assumes the default value of 1 The Hyperbolic distribution with parameters shape a and scale a has density proportional to F exp ay 1 for all x a gt Oando gt 0 The generation algorithm uses transformed density rejection TDR The parameters 1b and ub can be used to generate variates from the Hyperbolic distribution truncated to the interval 1b ub urlaplace 111 Not
19. T a is the function implemented by R s gamma and defined in its help The generation algorithm uses fast numerical inversion The parameters 1b and ub can be used to generate variates from the Powerexponential distribution truncated to the interval 1b ub Note This function is wrapper for the UNU RAN class in R Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg N L Johnson S Kotz and N Balakrishnan 1995 Continuous Univariate Distributions Volume 2 2nd edition John Wiley amp Sons Inc New York Chap 24 p 195 See Also runif and Random seed about random number generation and unuran for the UNU RAN class Examples Create a sample of size 1000 x lt urpowerexp n 1000 shape 4 urrayleigh 125 urrayleigh UNU RAN Rayleigh random variate generator Description UNU RAN random variate generator for the Rayleigh distribution with scale parameter scale It also allows sampling from the truncated distribution Special Generator Sampling Function Rayleigh Usage urrayleigh n scale 1 lb 0 ub Inf Arguments n size of required sample scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details If scale is omitted it a
20. between 0 and 1 lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Logarithmic distribution with parameters shape 0 has density f a log 1 0 0 x for x 1 2 and0 lt 0 lt 1 The generation algorithm uses guide table based inversion when the tails are not too heavy and method DARI otherwise The parameters 1b and ub can be used to generate variates from the Logarithmic distribution truncated to the interval 1b ub Note This function is a wrapper for the UNU RAN class in R Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg N L Johnson S Kotz and A W Kemp 1992 Univariate Discrete Distributions 2nd edition John Wiley amp Sons Inc New York Chap 7 p 285 urlogis 115 See Also runif and Random seed about random number generation and unuran for the UNU RAN class Examples Create a sample of size 1000 x lt urlogarithmic n 1000 shape 3 urlogis UNU RAN Logistic random variate generator Description UNU RAN random variate generator for the Logistic distribution with parameters location and scale It also allows sampling from the truncated distribution Special Generator Sampling Function Logistic Usage urlogis n location 0
21. generator object use method DGT inversion gen lt dgtd new dist Draw a sample of size 100 x lt ur gen 100 udhyperbolic UNU RAN object for Hyperbolic distribution Description Create UNU RAN object for a Hyperbolic distribution with location parameter mu tail shape parameter alpha asymmetry shape parameter beta and scale parameter delta Distribution Hyperbolic Usage udhyperbolic alpha beta delta mu lb Inf ub Inf Arguments alpha tail shape parameter must be strictly larger than absolute value of beta beta asymmetry shape parameter delta scale parameter must be strictly positive mu location parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The hyperbolic distribution with parameters u amp 8 and 6 has density proportional to f x exp arv 6 1 8 11 where a gt and gt 0 The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt udig 49 See Also unuran cont Examples Create distribution object for hyperbolic distribution distr lt udhyperbolic alpha 3 beta 2 delta 1 mu 0 Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udi
22. information about the distribution The setup time of this method depends on the given PDF whereas its marginal generation times are almost independent of the target distribution ARS is a special case of method TDR see tdr new It is a bit slower and less flexible but nu merically more stable In particular it is useful if one wants to sample from truncated distributions with extreme truncation points or when the integral of the given density function is only known to be extremely large or small However this assumes that the log density is computed analytically and not by just using log pdf x Value An object of class unuran Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Chapter 4 Tranformed Density Rejection W R Gilks and P Wild 1992 Adaptive rejection sampling for Gibbs sampling Applied Statistics 41 2 pp 337 348 See Also ur tdr new unuran cont unuran new unuran dari new 9 Examples Create a sample of size 100 for a Gaussian distribution use logPDF lpdf lt function x 5 x 2 gen lt ars new logpdf lpdf lb Inf ub Inf x lt ur gen 100 Same example but additionally provide derivative of log density to prevent possible round off errors lpdf lt fun
23. it can be any multiple of a probability vector The method runs fast in constant time i e marginal sampling times do not depend on the length of the given probability vector Whereas their setup times grow linearly with this length Notice that the range of random variates is from from length pv 1 Alternatively one can use function dgtd new where the object distr of class unuran discr must contain all required information about the distribution Value An object of class unuran Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Section 3 1 2 Indexed Search H C Chen and Y Asau 1974 On generating random variates from an empirical distribution AIE Trans 6 pp 163 166 See Also ur ug unuran discr unuran new unuran Examples Create a sample of size 100 for a binomial distribution with size 115 prob 0 5 gen lt dgt new pv dbinom 0 115 115 0 5 from 0 x lt ur gen 100 Alternative approach distr lt udbinom size 100 prob 0 3 gen lt dgtd new distr x lt ur gen 100 14 hitro new hitro new UNU RAN generator based on Hit and Run sampler HITRO Description UNU RAN random variate generator for continuous multivariate distributions with given proba bility density function P
24. lt unuran statmath wu ac at gt See Also unuran Examples Create a generator object that implements a rejection method unr lt tdrd new udnorm Verify hat and squeeze unuran verify hat unr up Distribution function for unuran object Description Evaluates the approximate cumulative distribution function CDF of a unuran object for a con tinuous or discrete distribution Usage up obj x 88 up Arguments obj one of e a distribution object of class unuran cont that contains the CDF or e a distribution object of class unuran discr that contains the CDF or e a generator object class unuran that contains a CDF or implements method PINV x vector of x values numeric Details The routine evaluates the cumulative distribution function of a distribution stored in a UNU RAN distribution object or UNU RAN generator object For the computation of the CDF the following alternatives are tried in the given order 1 The CDF is available in object obj the function is evaluated and the result is returned Important In this case routine up just evaluates the CDF but ignores the boundaries of the domain of the distribution i e it does not return 0 and 1 resp outside the domain unless the implementation of the CDF handles this case correctly This behavior is in particular important when Runuran built in distributions are truncated by explicitly setting the domain boundaries
25. new distr method pinv u_resolution 1e 12 unuran details Information on a given unuran generator object Description Prints type of unuran generator data used from distribution parameter for algorithm performance characteristic and hints to adjust the performance of the generator It also returns a list that contains some of these data Advanced Print object Usage unuran details unr show TRUE return list FALSE debug FALSE Arguments unr an unuran object show whether the data are printed on the console boolean return list whether some of the data are returned in a list boolean debug if TRUE store additional data in returned list This might be useful to examine a method boolean Details If show is TRUE then this routine prints data about the generator object to the console If return list is TRUE then a list that contains some of these data is returned This an experimental feature and components of the list may be extended on request The components of the returned list depend on the particular method However the following are common to all objects method string that contains the name of the generation method type one of the following strings that describes the type of the generation method inv inversion method ar acceptance rejection method iar acceptance rejection whether inversion is used for the proposal distribution mcmc Markov chain Monte Carlo sampler other none
26. 0 x lt ur gen 100 udpowerexp 63 udpowerexp UNU RAN object for Powerexponential distribution Description Create UNU RAN object for a Powerexponential Subbotin distribution with shape parameter shape Distribution Powerexponential Subbotin Usage udpowerexp shape lb Inf ub Inf Arguments shape strictly positive shape parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Powerexponential distribution with parameter shape 7 has density 1 T Fe gygy OPN for all z and 7 gt 0 Here T a is the function implemented by R s gamma and defined in its help The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Note This function is wrapper for the UNU RAN class in R Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1995 Continuous Univariate Distributions Volume 2 2nd edition John Wiley amp Sons Inc New York Chap 24 p 195 64 udrayleigh See Also unuran cont Examples Create distribution object for powerexponential distribution distr lt udpowerexp shape 4 Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udrayleigh UNU RAN object for Rayleigh dis
27. 1 0 0 x for x 1 2 and0 lt 0 lt 1 The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran discr Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and A W Kemp 1992 Univariate Discrete Distributions 2nd edition John Wiley Sons Inc New York Chap 7 p 285 See Also unuran discr 54 udlogis Examples Create distribution object for Logarithmic distribution dist lt udlogarithmic shape 0 3 Generate generator object use method DARI gen lt darid new dist Draw a sample of size 100 x lt ur gen 100 udlogis UNU RAN object for Logistic distribution Description Create UNU RAN object for a Logistic distribution with parameters location and scale Distribution Logistic Usage udlogis location 0 scale 1 lb Inf ub Inf Arguments location location parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Logistic distribution with location y and scale a has distribution function E 1 140 079 and density 1 e 2 1 0 o lF eCo f x The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu a
28. 1 44 46 49 52 55 57 60 61 64 67 69 71 76 81 84 88 unuran cont class 74 unuran cont new 6 30 75 75 83 138 unuran details 6 71 77 84 unuran discr 7 10 12 13 30 33 53 58 62 70 71 80 81 84 88 unuran discr class 78 unuran discr new 6 79 80 83 unuran distr 6 7 83 unuran distr class 81 unuran is inversion 82 unuran new 6 8 10 12 13 15 17 19 21 27 29 70 72 74 76 79 81 83 90 131 134 unuran packed 7 18 30 71 88 unuran packed unuran packed method 84 unuran packed unuran method unuran packed method 84 unuran packed method 84 unuran packed lt unuran packed method 84 unuran packed lt unuran method unuran packed method 84 unuran packed lt method unuran packed method 84 unuran sample ur 91 unuran verify hat 86 up 6 21 87 uq 5 6 13 18 21 84 85 89 ur 5 6 8 10 21 26 29 71 83 85 91 100 134 urbeta 24 92 urbinom 25 93 urburr 25 94 urcauchy 25 95 urchi 25 96 urchisq 25 98 urdau urdgt 99 urdgt 99 urexp 25 100 urextremel 25 101 urextremeIT 25 102 urf 25 104 urgamma 25 105 urgeom 25 106 urgig 25 107 urhyper 25 109 urhyperbolic 25 110 urlaplace 25 111 urlnorm 25 112 urlogarithmic 25 114 INDEX urlogis 25 115 urlomax 25 116 urnbinom 25 117 urnorm 25 119 urpareto 25 120 urplanck 25 121 urpois 25 122 urpowerexp 25 123 urra
29. 2 1 fa n a for x gt 0 The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 18 p 416 See Also unuran cont udexp 37 Examples Create distribution object for chi squared distribution distr lt udchisq df 5 Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udexp UNU RAN object for Exponential distribution Description Create UNU RAN object for an Exponential distribution with rate rate i e mean 1 rate Distribution Exponential Usage udexp rate 1 1b 0 ub Inf Arguments rate strictly positive rate parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Exponential distribution with rate has density Fa 0 for x gt 0 The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distribut
30. A Re 101 urextremell Vio Cae ea we Ee ee ee Ha eA a ee a Ge 102 Wh oi ede eae eho e tbe bt bebe eh eke ee ee bee ee eid 104 AA 105 AE NN 106 EPI sb a A ee ee a Gee ee eee bee pa e 107 WOhYPeO etica a ek Ra Re ey eon eR ded oy ee ee ee ee oo 109 Uy perboll sess se kG GOR A Bhar we eR A Ea SS Bacar ee de 110 UPlaplace canicas Ge geo Sky Sh ES BAe oe ae Ra RD Ae ala Sh amp Oa Raco e 111 UPIMOTM xr Bere Bee OG Hake Bede Rd Bale He ede Pd 112 urlogarithmic e ke a ee Be Ree SS Sw SRM ROSS Be he eed 114 IO LAS s fic ak hw Gs ee Ewe a ee ae he Ae ae al BR ea a wae 115 ps AA 116 UI DIMOM a auis de de e a e a AA ee ee ee A 117 R M ee fe oe ep ee Be GR we Ra ee EG we oe ee aE he ee ee i a 119 A e ie p ee DA th Wak ly ee ee Boe e a r a E te Be a eo ag 120 urplanck eco ra hin 2484 4b a4 PaO wad 4 121 UMPOIS e pee 448425 SNS ee Meee te beh eke ee eth a Ba eed SG 122 UTDOWETEXD om e a EE OEE ee ee ES 123 umayleigh 224866 e4 ne tad be bade baee Cet av bade Gade das 125 Ufi yene ee bee eb hod a eb Boe Ee Re 126 URADE Da SAE oy Soh SH BAL hoes e P de BAe Mao ees Gah sa 127 AAA eco Rls oe ae ee as Se Rls Be a ee a 128 USS AUX ONPE ra ia A Gee LARA She a ob eis 130 YITOUDEW 27 3 2 big MA A A E A E a 133 135 4 Runuran package Runuran package Runuran R interface to Universal Non Uniform RANdom variate generators library Description R interface to the UNU RAN library for Universal Non Uniform RANdom variate generators Det
31. Berlin Heidelberg See Chapter 4 Tranformed Density Rejection See Also ur ars new unuran cont unuran new unuran Examples Create a sample of size 100 for a Gaussian distribution pdf lt function x exp 5 x 2 gen lt tdr new pdf pdf lb Inf ub Inf x lt ur gen 100 Create a sample of size 100 for a Gaussian distribution use logPDF logpdf lt function x 0 5xx 2 gen lt tdr new pdf logpdf islog TRUE lb Inf ub Inf x lt ur gen 100 Same example but additionally provide derivative of log density to prevent possible round off errors logpdf lt function x 0 5xx 2 dlogpdf lt function x x gen lt tdr new pdf logpdf dpdf dlogpdf islog TRUE lb Inf ub Inf x lt ur gen 100 Draw sample from Gaussian distribution with mean 1 and standard deviation 2 Use dnorm gen lt tdr new pdf dnorm lb Inf ub Inf mean 1 sd 2 x lt ur gen 100 Draw a sample from a truncated Gaussian distribution on domain 5 Inf logpdf lt function x 0 5xx 2 gen lt tdr new pdf logpdf lb 5 ub Inf islog TRUE x lt ur gen 100 Alternative approach distr lt udnorm gen lt tdrd new distr x lt ur gen 100 ud Density function for unuran object 30 ud Description Evaluates the probability density function PDF or probability mass function PMF for a unuran object for a continuous and discrete di
32. DF It is based on the Hit and Run algorithm in combinaton with the Ratio of Uniforms method HITRO Universal MCMC Markov chain sampler Usage hitro new dim 1 pdf 11 NULL ur NULL mode NULL center NULL thinning 1 burnin 0 Arguments dim number of dimensions of the distribution integer pdf probability density function R function 11 ur lower left and upper right vertex of a rectangular domain of the pdf The domain 1s only set if both vertices are not NULL Otherwise the domain is unbounded by default numeric vectors mode location of the mode numeric vector center point in typical region of distribution e g the approximate location of the mode If omitted the mode is used If the mode is not given either the origin is used numeric vector thinning thinning factor positive integer burnin length of burnin in phase positive integer optional arguments for pdf Details Beware MCMC sampling can be dangerous This function creates a unuran object based on the Hit and Run algorithm in combinaton with the Ratio of Uniforms method HITRO It can be used to draw samples of a continuous random vector with given probability density function using ur The algorithm works best with log concave distributions Other distributions work as well but convergence can be slower The density must be provided by a function pdf which must return non negative numbers and but need not be normalized i e
33. DSC 2003 paper Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References J Leydold and W H ormann 2000 2007 UNU RAN User Manual see http statmath wu ac at unuran W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg G Tirler and J Leydold 2003 Automatic Nonuniform Random Variate Generation in R In K Hornik and F Leisch Proceedings of the 3rd International Workshop on Distributed Statistical Computing DSC 2003 March 20 22 Vienna Austria See Also unuran new and ur for faster creation and sampling routines unuran details for a more verbose version of show unuran packed allows to pack some unuran objects For distribution objects see unuran cont unuran discr and unuran cmv 72 unuran cmv class unuran cmv class Class unuran cmv for Continuous Multivariate Distribution Description Class unuran cmv provides an interface to UNU RAN objects for continuous multivariate distribu tions The interface might be changed in future releases Do not use unnamed arguments Advanced Continuous Multivariate Distribution Object Details Create a new instance of a unuran cmv object using new unuran cmv dim 1 pdf NULL 11 NULL ur NULL mode NULL center NULL name NA dim number of dimensions of the distribution integer pdf probability density function R func
34. Discrete Distribution Description Class unuran discr provides an interface to UNU RAN objects for discrete distributions The interface might be changed in future releases Do not use unnamed arguments Advanced Discrete Distribution Object unuran discr class 79 Details Create a new instance of a unuran discr object using new unuran discr cdf NULL pv NULL pmf NULL 1b NA ub NA mode NA sum NA name NA cdf cumulative distribution function R function pv probability vector numeric vector pmf probability mass function R function Ib lower bound of domain use Inf if unbounded from left numeric integer ub upper bound of domain use Inf if unbounded from right when pmf is not given the default ub Inf is used numeric integer mode mode of distribution numeric integer sum sum over pv pmf used for computing normalization constants if required numeric name name of distribution string The user is responsible that the given informations are consistent It depends on the chosen method which information must be given are used Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References J Leydold and W H ormann 2000 2007 UNU RAN User Manual see http statmath wu ac at unuran See Also unuran discr new unuran new unuran Examples Create discrete distribution with given probability vector the PV need not be normalize
35. Draw a sample of size 100 x lt ur gen 100 udcauchy UNU RAN object for Cauchy distribution Description Create UNU RAN object for a Cauchy distribution with location parameter location and scale parameter scale Distribution Cauchy Usage udcauchy location 0 scale 1 lb Inf ub Inf Arguments location location parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution 34 udchi Details The Cauchy distribution with location and scale s has density i 1 z 1 1 L TS 8 The domain of the distribution can be truncated to the interval 1b ub for all x Value An object of class unuran cont Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 16 p 299 See Also unuran cont Examples Create distribution object for Cauchy distribution distr lt udcauchy Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udchi UNU RAN object for Chi distribution Description Create UNU RAN object for a Chi distribution with df degrees of freedom Distribution Chi Usage udchi df 1b 0 ub In
36. Package Runuran August 19 2015 Type Package Title R Interface to the UNU RAN Random Variate Generators Version 0 23 0 Date 2015 08 18 Author Josef Leydold and Wolfgang H ormann Maintainer Josef Leydold lt josef leydoldewu ac at gt Depends R gt 3 0 0 Imports methods stats Description Interface to the UNU RAN library for Universal Non Uniform RANdom variate generators Thus it allows to build non uniform random number generators from quite arbitrary distributions In particular it provides an algorithm for fast numerical inversion for distribution with given density function In addition the package contains densities distribution functions and quantiles from a couple of distributions Collate unuran_distr R unuran_cont R unuran_discr R unuran_cmv R Runuran R universal R distributions R deprecated R zzz R License GPL gt 2 URL http statmath wu ac at unuran NeedsCompilation yes Repository CRAN Date Publication 2015 08 19 11 19 01 R topics documented Runuran package a pak e e E Ea e a poa Aa BISMEW Aiie ie a A n e a a A eae ee ee dar DEW aoa ago AA a RE ye SB daunew os eme a A Ee eta A A dStMewW 2 2 eee da da dow eA eee eee ee e oe ee MIPOMEW e o aoe Se et Bos BR os e ee R topics documented MOLDSW Sia a Be ieee aa BE e oe A tn Ge eee aie a 16 MIKE NEW emba a Gray Euk RAR em Bs eR ae ok Re a ce ee Sd 17 PINVNCW S 2 643 o PRR HS SERA SEES EA e Se re 19 Runuran distributions
37. RAN generator based on Adaptive Rejection Sampling ARS Description UNU RAN random variate generator for continuous distributions with given probability density function PDF It is based on Adaptive Rejection Sampling ARS Universal Rejection Method Usage ars new logpdf dlogpdf NULL lb ub arsd new distr 8 ars new Arguments logpdf log density function R function dlogpdf derivative of logpdf R function lb lower bound of domain use Inf if unbounded from left numeric ub upper bound of domain use Inf if unbounded from right numeric optional arguments for logpdf distr distribution object S4 object of class unuran cont Details This function creates a unuran object based on ARS Adaptive Rejection Sampling It can be used to draw samples from continuous distributions with given probability density function using ur Function logpdf is the logarithm the density function of the target distribution It must be a concave function i e the distribution must be log concave However it need not be normalized i e it can be a log density plus some arbitrary constant The derivative dlogpdf of the log density is optional If omitted numerical differentiation is used Notice however that this might cause some round off errors such that the algorithm fails Alternatively one can use function arsd new where the object distr of class unuran cont must contain all required
38. a sample of size 1000 x lt urlomax n 1000 shape 2 urnbinom UNU RAN Negative Binomial random variate generator Description UNU RAN random variate generator for the Negative Binomial distribution with with parameters size and prob It also allows sampling from the truncated distribution Special Generator Sampling Function Negative Binomial Usage urnbinom n size prob lb 0 ub Inf 118 urnbinom Arguments n size of required sample size target for number of successful trials or dispersion parameter the shape param eter of the gamma mixing distribution Must be strictly positive prob probability of success in each trial 4 lt prob lt 1 lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Negative Binomial distribution with size n and prob p has density D x mnm n 1 a zx p x Tael 1 p for x 0 1 2 n gt Oand 0 lt p lt 1 This represents the number of failures which occur in a sequence of Bernoulli trials before a target number of successes is reached The generation algorithm uses guide table based inversion when the tails are not too heavy and method DART otherwise The parameters 1b and ub can be used to generate variates from the Negative Binomial distribution truncated to the interval 1b ub Note This function is wrapper for the UNU RAN class in R Compared to rnbinom urnbinon is faster especially for larger s
39. a shape parameter alpha shape parameter must be strictly larger than absolute value of beta beta asymmetry shape parameter delta scale parameter must be strictly positive mu location parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The generalized hyperbolic distribution with parameters A a 8 and yu has density f x SK 8 hs x _ Pye T72 explblx 11 Kx 1 2 a 52 pa x 1 where the normalization constant is given by A Vr V2r ar 1 2 Ky 6 Q2 2 E t is the modified Bessel function of the third kind with index A Notice that a gt 8 and 6 gt 0 K The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References Barndorff Nielsen O Blaesild P 1983 Hyperbolic distributions In Johnson N L Kotz S Read C B Eds Encyclopedia of Statistical Sciences Vol 3 Wiley New York p 700 707 Prause K 1997 Modelling financial data using generalized hyperbolic distributions FDM preprint 48 University of Freiburg Prause K 1999 The generalized hyperbolic model Estimation financial derivatives and risk measures Ph D thesis University of Freiburg 44 udgig See Also unuran cont Examples Create distribution object for generalized hyperbolic distribution d
40. ails Package Runuran Type Package Version 0 23 0 Date 2015 08 18 License GPL 2 or later Runuran provides an interface to the UNU RAN library for universal non uniform random number generators It provides a collection of so called automatic methods for non uniform random vari ate generation Thus it is possible to draw samples from uncommon distributions Nevertheless some of these algorithms are also well suited for standard distribution like the normal distribution Moreover sampling from distributions like the generalized hyperbolic distribution is very fast Such distributions became recently popular in financial engineering Runuran compiles four sets of functions of increasing power and thus complexity Special Generator Generators for particular distributions Their syntax is similar to the corre sponding R built in functions Universal Functions that offer an interface to a carefully selected collection of UNU RAN methods with their most important parameters Distribution Functions that create objects for important distributions These objects can then be used in combination with one of the universal methods which is best suited for a particular application Advanced Wrapper to the UNU RAN string API This gives access to all UNU RAN methods and their variants We have marked all functions in their corresponding help page by one these four tags An introduction to Runuran with examples toget
41. ample sizes However in opposition to rnbinom vector arguments are ignored i e only the first entry is used Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation unuran for the UNU RAN class and rnbinon for the R built in generator Examples Create a sample of size 1000 x lt urnbinom n 1000 size 10 prob 0 3 urnorm 119 urnorm UNU RAN Normal random variate generator Description UNU RAN random variate generator for the Normal distribution with mean equal to mean and standard deviation to sd It also allows sampling from the truncated distribution Special Generator Sampling Function Normal Gaussian Usage urnorm n mean 0 sd 1 1b Inf ub Inf Arguments n size of required sample mean mean of distribution sd standard deviation lb lower bound of truncated distribution ub upper bound of truncated distribution Details If mean or sd are not specified they assume the default values of and 1 respectively The normal distribution has density 1 210 uy 20 f x where u is the mean of the distribution and the standard deviation The generation algorithm uses fast numerical inversion The parameters 1b and ub can be u
42. an cont unuran new unuran Examples Create a sample of size 100 for a Gaussian distribution pdf lt function x exp 5 x 2 gen lt srou new pdf pdf lb Inf ub Inf mode 0 area 2 506628275 x lt ur gen 100 Create a sample of size 100 for a Gaussian distribution Use dnorm gen lt srou new pdf dnorm lb Inf ub Inf mode 0 area 1 x lt ur gen 100 Alternative approach distr lt udnorm gen lt sroud new distr x lt ur gen 100 tdr new UNU RAN generator based on Transformed Density Rejection TDR Description UNU RAN random variate generator for continuous distributions with given probability density function PDF It is based on the Transformed Density Rejection method TDR Universal Rejection Method 28 tdr new Usage tdr new pdf dpdf NULL lb ub islog FALSE tdrd new distr Arguments pdf probability density function R function dpdf derivative of pdf R function lb lower bound of domain use Inf if unbounded from left numeric ub upper bound of domain use Inf if unbounded from right numeric islog whether pdf is given as log density the dpdf must then be the derivative of the log density boolean optional arguments for pdf distr distribution object S4 object of class unuran cont Details This function creates an unuran object based on TDR Transformed Density Rejection It can be used to draw samples o
43. and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 15 p 284 See Also unuran cont Examples Create distribution object for GIG distribution distr lt udgig theta 3 psi 1 chi 1 Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udgumbel UNU RAN object for Gumbel distribution Description Create UNU RAN object for a Gumbel Extreme value type I distribution location parameter location and scale parameter scale Distribution Gumbel Extreme value type I Usage udgumbel location 0 scale 1 lb Inf ub Inf 46 udgumbel Arguments location location parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Gumbel distribution function with location l and scale s is xl F x exp exp for all x The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1995 Continuous Univariate Distributions Volume 2 2nd edition John Wiley amp Sons Inc New York Chap 22 p 2 See Also unuran cont Examples
44. ape strictly positive shape parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Weibull distribution with shape parameter a and scale parameter has density given by f x a 0 2 0 exp 2 0 for x gt 0 The generation algorithm uses fast numerical inversion The parameters 1b and ub can be used to generate variates from the Weibull distribution truncated to the interval 1b ub Note This function is wrapper for the UNU RAN class in R Compared to rweibull urweibull is faster especially for larger sample sizes However in opposition to rweibull vector arguments are ignored i e only the first entry is used Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation unuran for the UNU RAN class and rweibull for the R built in generator Examples Create a sample of size 1000 x lt urweibull n 1000 shape 3 130 use aux umg method use aux urng method Use auxiliary random number generator for Runuran objects Description Some UNU RAN methods that are based on the rejection method can make use of a second auxiliary uniform random number generator It is only u
45. ated to the interval 1b ub Note This function is wrapper for the UNU RAN class in R Compared to rpois urpois is faster espe cially for larger sample sizes However in opposition to rpois vector arguments are ignored i e only the first entry is used Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation unuran for the UNU RAN class and rpois for the R built in generator Examples Create a sample of size 1000 from Poisson distribution with lamda 2 3 x lt urpois n 1000 lambda 2 3 urpowerex UNU RAN Powerexponential random variate generator p p Pp 8 Description UNU RAN random variate generator for the Powerexponential Subbotin distribution with shape parameter shape It also allows sampling from the truncated distribution Special Generator Sampling Function Powerexponential Subbotin Usage urpowerexp n shape lb Inf ub Inf 124 urpowerexp Arguments n size of required sample shape strictly positive shape parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Powerexponential distribution with parameter shape 7 has density 1 T FO yayi Uer for all z and 7 gt 0 Here
46. c at gt udlomax 55 References N L Johnson S Kotz and N Balakrishnan 1995 Continuous Univariate Distributions Volume 2 2nd edition John Wiley amp Sons Inc New York Chap 23 p 115 See Also unuran cont Examples Create distribution object for standard logistic distribution distr lt udlogis Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udlomax UNU RAN object for Lomax distribution Description Create UNU RAN object for a Lomax distribution Pareto distribution of second kind with shape parameter shape and scale parameter scale Distribution Lomax Pareto of second kind Usage udlomax shape scale 1 1b 0 ub Inf Arguments shape strictly positive shape parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Lomax distribution with parameters shape a and scale has density f z ao x 0 0 D for x gt 0 a gt Oando gt 0 The domain of the distribution can be truncated to the interval 1b ub 56 udmeixner Value An object of class unuran cont Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John W
47. cale Distribution Weibull Extreme value type MI Usage udweibull shape scale 1 1b 0 ub Inf Arguments shape strictly positive shape parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Weibull distribution with shape parameter a and scale parameter has density given by f x a o o exp x o for x gt 0 The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont 70 unuran class Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 21 p 628 See Also unuran cont Examples Create distribution object for Weibull distribution distr lt udweibull shape 3 Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 unuran class Class unuran Universal Non Uniform RANdom variate generators Description The class unuran provides an interface to the UNU RAN library for universal non uniform random number generators It uses the R built in uniform random number generator Advanced UNU RAN generator object Objects from the Class Object
48. cale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details If scale is omitted it assumes the default value of 1 The Gamma distribution with parameters shape a and scale a has density 1 Fa aT yl ale for x gt 0 a gt O and a gt 0 Here T a is the function implemented by R s gamma and defined in its help The generation algorithm uses fast numerical inversion The parameters 1b and ub can be used to generate variates from the Gamma distribution truncated to the interval 1b ub 106 urgeom Note This function is a wrapper for the UNU RAN class in R Compared to rgamma urgamma is faster especially for larger sample sizes However in opposition to rgamma vector arguments are ignored 1 e only the first entry is used Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation unuran for the UNU RAN class and rgamma for the R built in generator Examples Create a sample of size 1000 x lt urgamma n 1000 shape 2 urgeom UNU RAN Geometric random variate generator Description UNU RAN random variate generator for the Geometric distribution with parameter prob It also allows
49. cluster By packing an unuran object all required data are copied from the external object into an R list and stored in the unuran object while the external UNU RAN object is destroyed Thus the object can be handled like any other R object Moreover it can be still used as argument for ur and uq which may have even faster execution times then Packed unuran objects cannot be unpacked any more Notice that currently only objects that implement method PINV can be packed Methods Currently only objects that implement method PINV can be packed Note Note that due to limitations of floating point arithmetic the output of a uq call with the same input value for u may slightly differ for the packed and unpacked version See Also unuran pinv new Examples create a unuran object for half normal distribution using methed PINV gen lt pinv new dnorm 1b ub Inf status of object unuran packed gen draw a random sample of size 10 x lt ur gen 10 pack unuran object unuran packed gen lt TRUE unuran packed gen draw a random sample of size 10 x lt ur gen 10 Not run unpacking is not supported unuran packed gen lt FALSE results in error 86 unuran verify hat End Not run unuran verify hat Verify hat and squeezes in a unuran generator object Description Verify hat function and squeezes in a given unuran generator that implements a rejectio
50. ction x 5 x 2 dlpdf lt function x x gen lt ars new logpdf lpdf dlogpdf dlpdf lb Inf ub Inf x lt ur gen 100 Draw a sample from a truncated Gaussian distribution on domain 100 Inf lpdf lt function x 0 5xx 2 gen lt ars new logpdf lpdf 1b 50 ub Inf x lt ur gen 100 Alternative approach distr lt udnorm gen lt arsd new distr x lt ur gen 100 dari new UNU RAN generator based on Discrete Automatic Rejection Inversion DARI Description UNU RAN random variate generator for discrete distributions with given probability mass function PMP It is based on Discrete Automatic Rejection Inversion DARI Universal Rejection Method Usage dari new pmf 1b ub mode NA sum 1 darid new distr Arguments pmf probability mass function R function lb lower bound of domain use Inf if unbounded from left numeric integer ub upper bound of domain use Inf if unbounded from right numeric integer mode mode of distribution integer 10 dari new sum sum over all probabilities numeric optional arguments for pmf distr distribution object S4 object of class unuran discr Details This function creates an unuran object based on DARI Discrete Automatic Rejection Inversion It can be used to draw samples of a discrete random variate with given probability mass function using ur Function pmf must be p
51. d pv lt c 1 2 1 5 0 3 1 2 dpv lt new unuran discr pv pv lb 1 Create discrete distribution with given PMF pmf lt function x dbinom x 100 0 3 dpmf lt new unuran discr pmf pmf 1b 0 ub 100 80 unuran discr new unuran discr new Create a UNU RAN discrete univariate distribution object Description Create a new UNU RAN object for a discrete univariate distribution The interface might be changed in future releases Do not use unnamed arguments Advanced Discrete Distribution Usage unuran discr new cdf NULL pv NULL pmf NULL 1b NA ub NA mode NA sum NA name NA Arguments cdf cumulative distribution function R function pv probability vector numeric vector pmf probability mass function R function mode mode of distribution numeric integer lb lower bound of domain use Inf if unbounded from left numeric integer ub upper bound of domain use Inf if unbounded from right when pmf is not given the default ub Inf is used numeric integer sum sum over pv pmf used for computing normalization constants if required nu meric name name of distribution string Details Creates an instance of class unuran discr For more details see also unuran new The user is responsible that the given informations are consistent It depends on the chosen method which information must be given are used Note unuran discr new is an alias for new unuran discr
52. d collection of UNU RAN methods They require some data about the target distribution as arguments and return an instance of a UNU RAN generator object that is implemented as an S4 class unuran These can then be used to draw samples from the desired distribution by means of function ur Methods that implement an inversion method can also be used for quantile function uq Currently the following methods are available by such functions Continuous Univariate Distributions Function Method ars new Adaptive Rejection Sampling itdr new Inverse Transformed Density Rejection pinv new Polynomial interpolation of INVerse CDF srou new Simple Ratio Of Uniforms method tdr new Transformed Density Rejection Discrete Distributions Function Method dari new Discrete Automatic Rejection Inversion dau new Alias Urn Method dgt new Guide Table Method for discrete inversion Multivariate Distributions Function Method hitro new Hit and Run with Ratio of Uniforms method 6 Runuran package vnrou new Multivariate Naive Ratio Of Uniforms method Distribution Coding the required functions for particular distributions can be tedious Thus we have compiled a set of functions that create UNU RAN distribution objects that can directly be used with the functions from section Universal A list of all available distributions can be found in Runuran distributions Advanced This interface provides the mos
53. default values of and 1 respectively The Frechet distribution function with shape k location and scale s is l s F z p Ey for x gt l The generation algorithm uses fast numerical inversion The parameters 1b and ub can be used to generate variates from the Frechet distribution truncated to the interval 1b ub Note This function is a wrapper for the UNU RAN class in R Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg N L Johnson S Kotz and N Balakrishnan 1995 Continuous Univariate Distributions Volume 2 2nd edition John Wiley amp Sons Inc New York Chap 22 p 2 See Also runif and Random seed about random number generation and unuran for the UNU RAN class Examples Create a sample of size 1000 x lt urextremell n 1000 shape 2 104 urf urf UNU RAN F random variate generator Description UNU RAN random variate generator for the E distribution with with df1 and df2 degrees of free dom It also allows sampling from the truncated distribution Special Generator Sampling Function F Usage urf n df1 df2 1b 0 ub Inf Arguments n size of required sample df1 df2 strictly positive degrees of freedom Non integer values allowed lb lower bound of truncated distribution ub up
54. distribution Pareto distribution of second kind with shape parameter shape and scale parameter scale It also allows sampling from the truncated distribution Special Generator Sampling Function Lomax Usage urlomax n shape scale 1 1b 0 ub Inf Arguments n size of required sample shape strictly positive shape parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution urnbinom 117 Details If scale is omitted it assumes the default value of 1 The Lomax distribution with parameters shape a and scale has density fa 00 x 0 et for x gt 0 a gt Qand a gt 0 The generation algorithm uses fast numerical inversion The parameters 1b and ub can be used to generate variates from the Lomax distribution truncated to the interval 1b ub Note This function is a wrapper for the UNU RAN class in R Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 20 p 575 See Also runif and Random seed about random number generation and unuran for the UNU RAN class Examples Create
55. dnorm lb 2 ub Inf x lt ur gen 100 Improve the accuracy of the approximation gen lt pinv new pdf dnorm lb Inf ub Inf uresolution 1e 15 x lt ur gen 100 We have to provide a center when PDF almost vanishes at 0 gen lt pinv new pdf dgamma 1b 0 ub Inf center 4 shape 5 22 Runuran distributions x lt ur gen 100 We also can force a smoother approximation gen lt pinv new pdf dnorm lb Inf ub Inf smooth TRUE x lt ur gen 100 Alternative approach distr lt udnorm gen lt pinvd new distr x lt ur gen 100 Runuran distributions UNU RAN distribution objects Description Create objects for particular distributions suitable for using with generation methods from the UNU RAN library Details Runuran provides an interface to the UNU RAN library for universal non uniform random number generators This is a very flexible and powerful collection of sampling routines where the user first has to specify the target distribution and then has to choose an appropriate sampling method Creating an object for a particular distribution can be a bit tedious especially if the target distribution has a more complex density function Thus we have compiled a set of functions that provides ready to use distribution objects Moreover using these object often results in faster setup time than objects created with pure R code These functions share a similar syntax and naming schem
56. e This function is wrapper for the UNU RAN class in R Do not confuse with rhyper that samples from the discrete hypergeometric distribution Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation and unuran for the UNU RAN class Examples Create a sample of size 1000 from Hyperbolic distribution with shape 3 x lt urhyperbolic n 1000 shape 3 urlaplace UNU RAN Laplace random variate generator Description UNU RAN random variate generator for the Laplace double exponential distribution with loca tion parameter location and scale parameter scale It also allows sampling from the truncated distribution Special Generator Sampling Function Laplace Usage urlaplace n location 0 scale 1 lb Inf ub Inf Arguments n size of required sample location location parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution 112 urlnorm Details If location or scale are not specified they assume the default values of and 1 respectively The Laplace distribution with location and scale s has density x 1 f z exp for all z The generation algorithm us
57. e only ud is prefixed with analogous R built in functions that provide density distribution function and quantile ud distribution parameters lb ub Currently generators for the following distributions are implemented Continuous Univariate Distributions 26 Function Distribution udbeta Beta udcauchy Cauchy udchi Chi udchisq Chi squared udexp Exponential udf a E udfrechet Frechet Extreme value type II udgamma Gamma udghyp Generalized Hyperbolic udgig Generalized Inverse Gaussian Runuran distributions udgumbel udhyperbolic udig udlaplace udlnorm udlogis udlomax udmeixner udnorm udpareto udpowerexp udrayleigh udslash udt udvg udweibull Discrete Distributions 6 Author s Function udbinom udgeom udhyper udlogarithmic udnbinom udpois 23 Gumbel Extreme value type I Hyperbolic Inverse Gaussian Wald Laplace double exponential Log Normal Logistic Lomax Pareto of second kind Meixner Normal Gaussian Pareto of first kind Powerexponential Subbotin Rayleigh Slash t Student Variance Gamma Weibull Extreme value type ITI Distribution Binomial Geometric Hypergeometric Logarithmic Negative Binomial Poisson Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt See Also Runuran package Examples Create an object for a gamma distribution with shape parameter 5 distr lt udgamma shape 5
58. e Also unuran cont unuran discr unuran cmv unuran 82 unuran is inversion unuran is inversion Test whether a unuran generator object implements an inversion method Description Test whether a given unuran generator object implements an inversion method Advanced Test type of method Usage unuran is inversion unr Arguments unr a unuran object Details A unuran object may implement quite a couple of generation methods This function tests whether the method used in unr is an approximate inversion method It returns TRUE when unr implements an inversion method and FALSE otherwise Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt See Also unuran Examples HH PINV is an inversion method unr lt pinvd new udnorm unuran is inversion unr TDR is a rejection method unr lt tdrd new udnorm unuran is inversion unr unuran new 83 unuran new Create a UNU RAN object Description Create a new unuran object in package Runuran that can be used for sampling from the specified distribution The function ur can then be used to draw a random sample Advanced Create generator object Usage unuran new distr method auto Arguments distr a string or an S4 class describing the distribution method a string describing the random variate generation method Details This function creates an instance of S4 class unuran whic
59. ect use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udfrechet UNU RAN object for Frechet distribution Description Create UNU RAN object for a Frechet Extreme value type II distribution with shape parameter shape location parameter location and scale parameter scale Distribution Frechet Extreme value type II Usage udfrechet shape location 0 scale 1 lb location ub Inf Arguments shape strictly positive shape parameter location location parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Frechet distribution function with shape k location l and scale s is A ae F a exp for x gt l The domain of the distribution can be truncated to the interval 1b ub 40 udgamma Value An object of class unuran cont Note This function is a wrapper for the UNU RAN class in R Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1995 Continuous Univariate Distributions Volume 2 2nd edition John Wiley amp Sons Inc New York Chap 22 p 2 See Also unuran cont Examples Create distribution object for Frechet distribution distr lt udfrechet shape 2 Generate generator object use method PINV inversion gen
60. ed distribution numeric Details This function creates a unuran object based on SROU Simple Ratio Of Uniforms Method It can be used to draw samples of a continuous random variate with given probability density function using ur The density pdf must be positive but need not be normalized i e it can be any multiple of a density function It must be T concave for c r r 1 this includes all log concave distributions The exact location of the mode and the area below the pdf are essential Alternatively one can use function sroud new where the object distr of class unuran cont must contain all required information about the distribution tdr new 27 The acceptance probability decreases with increasing parameter r Thus it should be as small as possible On the other hand it must be sufficiently large for heavy tailed distributions If possible use the default r 1 Compared to tdr new it has much slower marginal generation times but has a faster setup and is numerically more robust Moreover It also works for unimodal distributions with tails that are heavier than those of the Cauchy distribution Value An object of class unuran Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg Sections 6 3 and 6 4 See Also ur unur
61. ef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation unuran for the UNU RAN class and rexp for the R built in generator Examples Create a sample of size 1000 x lt urexp n 1000 urextremel UNU RAN Extreme value type I Gumbel type random variate gener ator Description UNU RAN random variate generator for the Extreme value type I Gumbel type distribution with location parameter location and scale parameter scale It also allows sampling from the truncated distribution Special Generator Sampling Function Gumbel extreme value type I Usage urextremel n location 0 scale 1 lb Inf ub Inf Arguments n size of required sample location location parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution 102 urextremell Details If location or scale are not specified they assume the default values of and 1 respectively The Gumbel distribution with location l and scale s has distribution function Pla pap for all x The generation algorithm uses fast numerical inversion The parameters 1b and ub can be used to generate variates from the Gumbel distribution truncated to the in
62. eginner Thus we have prepared easy to use sampling functions for standard distributions to facilitate the use of the package All these functions share a similar syntax and naming scheme only u is pre fixed with their analogous R built in generating functions if these exist but have optional domain arguments lb and ub i e these calls also allow to draw samples from truncated distributions ur n distribution parameters lb ub These functions also show the interested user how we used the more powerful functions We recom mend to directly use these more flexible functions Then one has faster marginal generation times and one may choose the best generation method for one s application Currently generators for the following distributions are implemented Continuous Univariate Distributions 24 Function Distribution urbeta Beta Runuran special generators urburr urcauchy urchi urchisq urexp urextremel urextremell urf urgamma urgig urhyperbolic urlaplace urlnorm urlogis urlomax urnorm urpareto urplanck urpowerexp urrayleigh urt urtriang urweibull Discrete Distributions 6 Function urbinom urgeom urhyper urlogarithmic urnbinom urpois Author s 25 Burr Cauchy Chi Chi squared Exponential Gumbel extreme value type I Frechet extreme value type II F Gamma GIG generalized inverse Gaussian Hyperbolic Laplace Log Normal Logistic Lomax Normal Gaussian Pare
63. egrees of freedom It also allows sampling from the truncated distribution Do not confuse with the Chi Squared 7 distribution Special Generator Sampling Function Chi urchi 97 Usage urchi n df 1b 0 ub Inf Arguments n size of required sample df degrees of freedom strictly positive but can be non integer lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Chi distribution with df n gt 0 degrees of freedom has density f z gle 2 2 for x gt 0 The generation algorithm uses fast numerical inversion The parameters lb and ub can be used to generate variates from the Chi distribution truncated to the interval 1b ub Note This function is wrapper for the UNU RAN class in R Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 18 p 417 See Also runif and Random seed about random number generation and unuran for the UNU RAN class Examples Create a sample of size 1000 x lt urchi n 1000 df 3 98 urchisq urchisq UNU RAN Chi Squared random variate generator Description UNU RAN random variate gene
64. er lb lower bound of truncated distribution ub upper bound of truncated distribution Details The distribution with df v degrees of freedom has density y ADD am f x ATOA 1 2 v for all real x It has mean 0 for y gt 1 and variance Ja for v gt 2 The generation algorithm uses fast numerical inversion The parameters 1b and ub can be used to generate variates from the t distribution truncated to the interval 1b ub Note This function is a wrapper for the UNU RAN class in R Compared to rt urt is faster especially for larger sample sizes However in opposition to rt vector arguments are ignored i e only the first entry is used urtriang 127 Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation unuran for the UNU RAN class and rt for the R built in generator Examples Create a sample of size 1000 x lt urt n 1000 df 4 urtriang UNU RAN Triangular random variate generator Description UNU RAN random variate generator for the Triangular distribution with shape parameters a m and b It also allows sampling from the truncated distribution Special Generator Sampling Function Triangular Usage urtriang n a m b lb a ub b Arg
65. er Verlag Berlin Heidelberg B W Schmeiser and V Kachitvichyanukul 1986 Correlation induction without the inverse trans formation In Proc 1986 Winter Simulation Conf J Wilson J Henriksen S Roberts eds 266 274 B W Schmeiser and V Kachitvichyanukul 1990 Non inverse correlation induction guidelines for algorithm development J Comput Appl Math 31 173 180 W H ormann and G Derflinger 1994 Universal generators for correlation induction In Comp stat Proceedings in Computational Statistics R Dutter and W Grossmann eds 52 57 J Leydold E Janka and W H ormann 2002 Variants of Transformed Density Rejection and Correlation Induction In Monte Carlo and Quasi Monte Carlo Methods 2000 K T Fang F Hickernell and H Niederreiter eds 345 356 P L Ecuyer and R Touzin 2000 Fast combined multiple recursive generators with multipliers of the form a 2 q 24r In J A Jones R R Barton K Kang and P A Fishwick eds Proc 2000 Winter Simulation Conference 683 689 See Also tdr new Examples Create respective generators for normal and exponential distribution Use method TDR gen1 lt tdrd new udnorm gen2 lt tdrd new udexp The two streams are independent even we use the same seed set seed 123 x1 lt ur gen1 1e5 set seed 123 x2 lt ur gen2 1e5 cor x1 x2 We can enable the auxiliary URNG and get correlated streams use aux ur
66. er left and upper right vertex of a rectangular domain of the pdf The domain is only set if both vertices are not NULL Otherwise the domain is unbounded by default numeric vectors mode location of the mode numeric vector center point in typical region of distribution e g the approximate location of the mode If omitted the mode is used If the mode is not given either the origin is used numeric vector optional arguments for pdf 134 vnrou new Details This function creates a unuran object based on the naive ratio of uniforms method VNROU i e a bounding rectangle for the acceptance region is estimated and use for sampling proposal points It can be used to draw samples of a continuous random vector with given probability density function using ur The algorithm works with unimodal distributions provided that the tails are not too high in every direction The density must be provided by a function pdf which must return non negative numbers and which need not be normalized i e it can be any multiple of a density function The center is used as starting point for computing the bounding rectangle Alternatively one also could provide the location the mode However this requires its exact position whereas center allows any point in the typical region of the distribution The setup can be accelerated when the mode is given Author s Josef Leydold and Wolfgang H ormann lt unuran statmath w
67. es fast numerical inversion The parameters 1b and ub can be used to generate variates from the Laplace distribution truncated to the interval 1b ub Note This function is a wrapper for the UNU RAN class in R Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg N L Johnson S Kotz and N Balakrishnan 1995 Continuous Univariate Distributions Volume 2 2nd edition John Wiley amp Sons Inc New York Chap 24 p 164 See Also runif and Random seed about random number generation and unuran for the UNU RAN class Examples Create a sample of size 1000 x lt urlaplace n 1000 urlnorm UNU RAN Log Normal random variate generator Description UNU RAN random variate generator for the Log Normal distribution whose logarithm has mean equal to meanlog and standard deviation equal to sdlog It also allows sampling from the truncated distribution Special Generator Sampling Function Log Normal Usage urlnorm n meanlog 0 sdlog 1 1b 0 ub Inf urlnorm 113 Arguments n size of required sample meanlog sdlog mean and standard deviation of the distribution on the log scale If not not specified they assume the default values of and 1 respectively lb lower bound of truncated distribution ub upper bound of truncated
68. eter scale Distribution Laplace double exponential Usage udlaplace location 0 scale 1 lb Inf ub Inf Arguments location location parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution udInorm 51 Details The Laplace distribution with location and scale s has density x 1 f z exp for all x The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1995 Continuous Univariate Distributions Volume 2 2nd edition John Wiley amp Sons Inc New York Chap 24 p 164 See Also unuran cont Examples Create distribution object for standard Laplace distribution distr lt udlaplace Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udlnorm UNU RAN object for Log Normal distribution Description Create UNU RAN object for a Log Normal distribution whose logarithm has mean equal to meanlog and standard deviation equal to sdlog Distribution Log Normal Usage udlnorm meanlog 0 sdlog 1 1b 0 ub Inf 52 udInorm Arguments meanlog mean of the distribution on the log scale sdlog s
69. f udchi 35 Arguments df degrees of freedom strictly positive Non integer values allowed lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Chi distribution with df n gt 0 degrees of freedom has density f z rte a 2 for x gt 0 The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 18 p 417 See Also unuran cont Examples Create distribution object for chi squared distribution distr lt udchi df 5 Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 36 udchisq udchisq UNU RAN object for Chi Squared distribution Description Create UNU RAN object for a Chi squared x distribution with df degrees of freedom Distribution Chi squared Usage udchisq df 1b 0 ub Inf Arguments df degrees of freedom strictly positive Non integer values allowed lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Chi squared distribution with df n gt 0 degrees of freedom has density n 2 1 77
70. f a continuous random variate with given probability density function using ur The density pdf must be positive but need not be normalized i e it can be any multiple of a density function The derivative dpdf of the log density is optional If omitted numerical differentiation is used Notice however that this might cause some round off errors such that the algorithm fails This is in particular the case when the density function is provided instead of the log density The given pdf must be T_o 5 concave with implies unimodal densities with tails not higher than 1 z this includes all log concave distributions It is recommended to use the log density instead of the density function as this is numerically more stable Alternatively one can use function tdrd new where the object distr of class unuran cont must contain all required information about the distribution The setup time of this method depends on the given PDF whereas its marginal generation times are almost independent of the target distribution There exists a variant of TDR which is numerically more stable albeit a bit slower and less flexible which is avaible via the ars new function Value An object of class unuran Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt ud 29 References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag
71. g one non uniform random variate This can be accomplished by means of a second auxiliary stream of URNs which is used when the required number of URNs exceeds k By this approach two streams of non uniform random variates run synchronized except when a rejection occurs in one of the two streams Therefore the two generated streams are respected mix tures of highly correlated streams and independent streams The induced correlation thus decreases when the rejection constants of the acceptance rejection algorithms used for generating the two streams increases In UNU RAN some of the acceptance rejection algorithms make use of a second auxiliary stream of URNS It is implemented in one of the following ways use aux urng method 131 e The primary uniform random number generator is used for the first loop of the acceptance rejection step When a rejection occurs the algorithms switches to auxiliary generator until the proposal point is accepted Thus exactly two URNs from the primary generator are used to generate one non uniform random variate e The primary uniform random number generator is used just for the first proposal point and then switches to the auxiliary generator until the proposal point is accepted Thus exactly one URN from the primary generator is used to generate one non uniform random variate The call use aux urng unr returns FALSE if this feature is disabled for Runuran generator object unr the default and TRUE if this fea
72. g UNU RAN object for Inverse Gaussian distribution Description Create UNU RAN object for a Inverse Gaussian Wald distribution with mean mu and shape pa rameter lambda Distribution Inverse Gaussian Wald Usage udig mu lambda 1b 0 ub Inf Arguments mu mean strictly positive lambda shape parameter strictly positive lb lower bound of truncated distribution ub upper bound of truncated distribution Details The inverse Gaussian distribution with mean y and shape parameter A has density A or A z py 2u x where u gt 0 and A gt 0 The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont 50 udlaplace Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 15 p 259 See Also unuran cont Examples Create distribution object for inverse Gaussian distribution distr lt udig mu 3 lambda 2 Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udlaplace UNU RAN object for Laplace distribution Description Create UNU RAN object for a Laplace double exponential distribution with location parameter location and scale param
73. generators 5 7 24 rweibull 29 set aux seed use aux urng method 130 set seed 6 show unuran method unuran class 70 show unuran cmv method unuran cmv class 72 show unuran cont method unuran cont class 74 show unuran discr method unuran discr class 78 show unuran distr method unuran distr class 81 SpecialGenerator Runuran special generators 24 srou new 5 26 sroud new srou new 26 tdr new 5 8 27 27 131 132 tdrd new tdr new 27 ud 6 29 137 udbeta 22 31 udbinom 23 32 udcauchy 22 33 udchi 22 34 udchisgq 22 36 udexp 22 37 udf 22 38 udfrechet 22 39 udgamma 22 40 udgeom 23 41 udghyp 22 42 udgig 22 44 udgiga udgig 44 udgumbel 23 45 udhyper 23 47 udhyperbolic 23 48 udig 23 49 udlaplace 23 50 udlnorm 23 51 udlogarithmic 23 53 udlogis 23 54 udlomax 23 55 udmeixner 23 56 udnbinom 23 58 udnorm 23 59 udpareto 23 60 udpois 23 61 udpowerexp 23 63 udrayleigh 23 64 udslash 23 65 udt 23 66 udvg 23 67 udweibull 23 69 unuran 5 8 10 12 13 15 17 19 21 27 29 30 71 72 74 76 78 79 81 85 87 88 90 91 93 97 99 101 103 105 108 110 113 115 118 120 124 126 129 134 unuran Runuran package 4 unuran class 70 unuran cmv 70 71 73 74 81 84 unuran cmv class 72 unuran cmv new 6 72 73 83 unuran cont 7 8 17 21 27 29 30 32 34 36 38 4
74. ger Verlag Berlin Heidelberg H C Chen and Y Asau 1974 On generating random variates from an empirical distribution AIHE Trans 6 pp 163 166 A J Walker 1977 An efficient method for generating discrete random variables with general distributions ACM Trans Model Comput Simul 3 pp 253 256 See Also dau new dgt new and ur for replacement urexp UNU RAN Exponential random variate generator Description UNU RAN random variate generator for the Exponential distribution with rate rate i e mean 1 rate It also allows sampling from the truncated distribution Special Generator Sampling Function Exponential Usage urexp n rate 1 1b 0 ub Inf Arguments n size of required sample rate strictly positive rate parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details If rate is not specified it assumes the default value of 1 The Exponential distribution with rate has density f x re for x gt 0 The generation algorithm uses fast numerical inversion The parameters 1b and ub can be used to generate variates from the Exponential distribution truncated to the interval 1b ub urextremel 101 Note This function is a wrapper for the UNU RAN class in R Compared to rexp urexp is faster es pecially for larger sample sizes However in opposition to rexp vector arguments are ignored i e only the first entry is used Author s Jos
75. h contains a generator for the target dis tribution This distribution has to be provided as an instance of S4 class unuran distr Depending on the type of distribution such an instance can be created by unuran cont new for univariate continuous distributions unuran discr new for discrete distributions and unuran cmv new for multivariate continuous distributions The generation can be chosen by passing method to the UNU RAN String API The default method auto tries to find an appropriate method for the given distribution However this method is experimental and is yet not very powerfull Once a unuran object has been created it can be used to draw random samples from the target distribution using ur Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg 84 unuran packed method See Also See unuran for the UNU RAN class of generators See unuran details for printing details about the generator object and ur and uq for sampling and quantile function respectively For distribution objects see unuran cont unuran discr and unuran cmv runif Random seed about random number generation in R Examples Use method TDR Transformed Density Rejection to draw a sample of size 10 from a hyperbolic distribution with PDF f x const e
76. he distribution can be truncated to the interval 1b ub Value An object of class unuran cont Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1995 Continuous Univariate Distributions Volume 2 2nd edition John Wiley amp Sons Inc New York Chap 28 p 362 See Also unuran cont Examples Create distribution object for t distribution distr lt udt df 4 Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udvg UNU RAN object for Variance Gamma distribution Description Create UNU RAN object for a Variance Gamma distribution with shape parameter lambda shape parameter alpha asymmetry shape parameter beta and location parameter mu Distribution Variance Gamma Usage udvg lambda alpha beta mu lb Inf ub Inf 68 udvg Arguments lambda shape parameter must be strictly positive alpha shape parameter must be strictly larger than absolute value of beta beta asymmetry shape parameter mu location parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The variance gamma distribution with parameters A a 3 and u has density f x e pl exp a 1 Ky1 2 ala pl where the normalization constant is given by K t is the modif
77. her with a very short survey on non uniform random variate generation can be found in the package vignette which can be displayed using vignette Runuran Special Generator These functions have similar syntax to the analogous R built in generating functions if these exist but have optional domain arguments lb and ub i e these calls also allow to draw samples from truncated distributions Runuran package 5 ur n distribution parameters lb ub Compared to the corresponding R functions these ur functions have a different behavior ur functions are often much faster for large samples e g a factor of about 5 for the t distribution For small samples they are slow All ur functions allow to sample from truncated versions of the original distributions Therefore the arguments 1b lower border and ub upper border are available for all these functions Almostall ur functions are based on fast numerical inversion algorithms This is important for example for generating order statistics quasi Monte Carlo methods or random vectors from copulas All ur functions do not allow vectors as arguments to be more precise they only use the first element of the vector However we recommend to use the more flexible approach described in the next sections below A list of all available special generators can be found in Runuran special generators Universal These functions allow access to a selecte
78. iate generator for continuous distributions with given probability density function PDF or cumulative distribution function CDF It is based on the Polynomial interpola tion of INVerse CDF PINV Universal Inversion Method 20 pinv new Usage pinv new pdf cdf lb ub islog FALSE center 0 uresolution 1 e 10 smooth FALSE pinvd new distr uresolution 1 e 10 smooth FALSE Arguments pdf probability density function R function cdf cumulative distribution function R function lb lower bound of domain use Inf if unbounded from left numeric ub upper bound of domain use Inf if unbounded from right numeric islog whether pdf and cdf are given by their corresponding logarithms boolean center typical point of distribution numeric optional arguments for pdf and cdf distr distribution object S4 object of class unuran cont uresolution maximal acceptable u error numeric smooth whether the inverse CDF is differentiable boolean Details This function creates an unuran object based on PINV Polynomial interpolation of INVerse CDF It can be used to draw samples of a continuous random variate with given probability density function pdf or cumulative distribution function cdf by means of ur It also allows to compute quantiles by means of uq Function pdf must be positive but need not be normalized i e it can be any multiple of a density function The set of points where the
79. ied Bessel function of the third kind with index A T t is the Gamma function Notice that a gt B and A gt 0 The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Note For A lt 0 5 the density has a pole at p Author s Josef Leydold and Kemal Dingec lt unuran statmath wu ac at gt References Eberlein E von Hammerstein E A 2004 Generalized hyperbolic and inverse Gaussian distribu tions limiting cases and approximation of processes In Seminar on Stochastic Analysis Random Fields and Applications IV Progress in Probability 58 R C Dalang M Dozzi F Russo Eds Birkhauser Verlag p 221 264 Madan D B Seneta E 1990 The variance gamma V G model for share market returns Journal of Business Vol 63 p 511 524 Raible S 2000 LVevy Processes in Finance Theory Numerics and Empirical Facts Ph D thesis University of Freiburg udweibull 69 See Also unuran cont Examples Create distribution object for variance gamma distribution distr lt udvg lambda 2 25 alpha 210 5 beta 5 14 mu 0 00094 Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udweibull UNU RAN object for Weibull distribution Description Create UNU RAN object for a Weibull Extreme value type III distribution with with parameters shape and s
80. iley amp Sons Inc New York Chap 20 p 575 See Also unuran cont Examples Create distribution object for Lomax distribution distr lt udlomax shape 2 Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udmeixner UNU RAN object for Meixner distribution Description Create UNU RAN object for a Meixner distribution with scale parameter alpha asymmetry shape parameter beta shape parameter delta and location parameter mu Distribution Meixner Usage udmeixner alpha beta delta mu lb Inf ub Inf Arguments alpha scale parameter must be strictly positive beta asymmetry shape parameter must be larger than 7 and smaller than 7 delta shape parameter must be strictly positive mu location parameter lb lower bound of truncated distribution ub upper bound of truncated distribution udmeixner 57 Details The Mexiner distribution with parameters a 8 6 and u has density f x s exp B a u a E 8 i a 1 a where the normalization constant is given by 2 cos 8 2 2am T 20 The symbol denotes the imaginary unit that is we have to evaluate the gamma function T z for complex arguments z x iy Notice that a gt 0 8 lt 7 and gt 0 The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont
81. iley amp Sons Inc New York Chap 25 p 210 See Also unuran cont Examples Create distribution object for beta distribution distr lt udbeta shape1 3 shape2 7 Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udbinom UNU RAN object for Binomial distribution Description Create UNU RAN object for a Binomial distribution with parameters size and prob Distribution Binomial Usage udbinom size prob 1b 0 ub size Arguments size number of trials one or more prob probability of success on each trial lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Binomial distribution with size n and prob p has probability mass function ote ej forx 0 n The domain of the distribution can be truncated to the interval 1b ub udcauchy 33 Value An object of class unuran discr Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and A W Kemp 1992 Univariate Discrete Distributions 2nd edition John Wiley amp Sons Inc New York Chap 3 p 105 See Also unuran discr Examples Create distribution object for Binomial distribution dist lt udbinom size 100 prob 0 33 Generate generator object use method DGT inversion gen lt dgtd new dist
82. ion Create UNU RAN object for a Geometric distribution with parameter prob Distribution Geometric Usage udgeom prob lb 0 ub Inf 42 udghyp Arguments prob probability of success in each trial lt prob lt 1 lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Geometric distribution with prob p has density p x p 1 p forx 0 1 2 0 lt p lt l The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran discr Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and A W Kemp 1992 Univariate Discrete Distributions 2nd edition John Wiley amp Sons Inc New York Sect 5 2 p 201 Examples Create distribution object for Geometric distribution dist lt udgeom prob 33 Generate generator object use method DARI gen lt darid new dist Draw a sample of size 100 x lt ur gen 100 udghyp UNU RAN object for Generalized Hyperbolic distribution Description Create UNU RAN object for a Generalized Hyperbolic distribution with shape parameter lambda shape parameter alpha asymmetry shape parameter beta scale parameter delta and location parameter mu Distribution Generalized Hyperbolic udghyp 43 Usage udghyp lambda alpha beta delta mu lb Inf ub Inf Arguments lambd
83. ions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 19 p 494 38 udf See Also unuran cont Examples Create distribution object for standard exponential distribution distr lt udexp Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udf UNU RAN object for F distribution Description Create UNU RAN object for an F distribution with mean with df1 and df2 degrees of freedom Distribution F Usage udf df1 df2 1b 0 ub Inf Arguments df1 df2 strictly positive degrees of freedom Non integer values allowed lb lower bound of truncated distribution ub upper bound of truncated distribution Details The F distribution with df1 m and df2 na degrees of freedom has density ae T m1 2 n2 2 ee 7 21 oo Tn D0 2 2 Una ira for x gt 0 The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt udfrechet 39 References N L Johnson S Kotz and N Balakrishnan 1995 Continuous Univariate Distributions Volume 2 2nd edition John Wiley amp Sons Inc New York Chap 27 p 332 See Also unuran cont Examples Create distribution object for F distribution distr lt udf df1 3 df2 6 Generate generator obj
84. is method depends on the given PDF whereas its marginal generation times are almost independent of the target distribution mixt new 17 Value An object of class unuran Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2007 Inverse transformed density rejection for unbounded monotone densities ACM Trans Model Comput Simul 17 4 Article 18 16 pages DOI 10 1145 1276927 127693 1 See Also ur unuran cont unuran new unuran Examples Create a sample of size 100 for a Gamma 0 5 distribution pdf lt function x x 5 exp x dpdf lt function x x 5 5 x 1 5 exp x gen lt itdr new pdf pdf dpdf dpdf 1b 8 ub Inf pole 0 x lt ur gen 100 Alternative approach distr lt udgamma shape 5 gen lt itdrd new distr x lt ur gen 100 mixt new UNU RAN generator for finite mixture of distributions Description UNU RAN random variate generator for a finite mixture of continuous or discrete distributions The components are given as unuran objects Universal Composition Method Usage mixt new prob comp inversion FALSE 18 mixt new Arguments prob weights of mixture probabilities these must be non negative numbers but need not sum to 1 numeric vector comp components of mixture list of S4 object of class unuran inversion whether in
85. istr lt udghyp lambda 1 0024 alpha 39 6 beta 4 14 delta 0 0118 mu 0 000158 Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udgig UNU RAN object for Generalized Inverse Gaussian distribution Description Create UNU RAN object for a Generalized Inverse Gaussian distribution Two parametrizations are available Distribution Generalized Inverse Gaussian Usage udgig theta psi chi 1b 0 ub Inf udgiga theta omega eta 1 1b 0 ub Inf Arguments theta shape parameter psi chi shape parameters must be strictly positive omega eta shape parameters must be strictly positive lb lower bound of truncated distribution ub upper bound of truncated distribution Details The generalized inverse Gaussian distribution with parameters 6 Y and x has density proportional to inet 5 ve 2 where 4 gt 0 and x gt 0 An alternative parametrization used parameters 0 w and y and has density proportional to dE The domain of the distribution can be truncated to the interval 1b ub udgumbel 45 Value An object of class unuran cont Note These two parametrizations can be converted into each other by means of the following transforma tions w y x wn n X w xv n y T Y Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References N L Johnson S Kotz
86. k k gt 0anda gt 0 The generation algorithm uses fast numerical inversion The parameters 1b and ub can be used to generate variates from the Pareto distribution truncated to the interval 1b ub Note This function is wrapper for the UNU RAN class in R Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt urplanck 121 References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 20 p 574 See Also runif and Random seed about random number generation and unuran for the UNU RAN class Examples Create a sample of size 1000 x lt urpareto n 1000 k 2 a 3 urplanck UNU RAN Planck random variate generator Description UNU RAN random variate generator for the Planck distribution with shape parameter a It also allows sampling from the truncated distribution Special Generator Sampling Function Planck Usage urplanck n a lb 1 e 12 ub Inf Arguments n size of required sample a strictly positive shape parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Planck distribution with parameter a has density proportional to qe Ha exp 1 1 for x gt Qanda gt
87. ked method 84 unuran verify hat 86 uq 89 ur 91 urdgt 99 use aux urng method 130 vnrou new 133 Topic distribution 135 ars new 7 dari new 9 dau new 11 dgt new 12 hitro new 14 itdr new 16 mixt new 17 pinv new 19 Runuran package 4 Runuran distributions 22 Runuran special generators 24 srou new 26 tdr new 27 udbeta 31 udbinom 32 udcauchy 33 udchi 34 udchisq 36 udexp 37 udf 38 udfrechet 39 udgamma 40 udgeom 41 udghyp 42 udgig 44 udgumbel 45 udhyper 47 udhyperbolic 48 udig 49 udlaplace 50 udlnorm 51 udlogarithmic 53 udlogis 54 udlomax 55 udmeixner 56 udnbinom 58 udnorm 59 udpareto 60 udpois 61 136 udpowerexp 63 udrayleigh 64 udslash 65 udt 66 udvg 67 udweibull 69 unuran class 70 unuran cmv class 72 unuran cmv new 73 unuran cont class 74 unuran cont new 75 unuran details 77 unuran discr class 78 unuran discr new 80 unuran distr class 81 unuran new 83 unuran packed method 84 unuran verify hat 86 uq 89 ur 91 urbeta 92 urbinom 93 urburr 94 urcauchy 95 urchi 96 urchisq 98 urdgt 99 urexp 100 urextremel 101 urextremelI 102 urf 104 urgamma 105 urgeom 106 urgig 107 urhyper 109 urhyperbolic 110 urlaplace 111 urlnorm 112 urlogarithmic 114 urlogis 115 urlomax 116 urnbinom 117 urnorm 119 urpareto 120 urplanck 121 urpois 122 urpowerexp 123 urrayleigh 125 INDEX urt 126 ur
88. mann lt unuran statmath wu ac at gt 60 udpareto References N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 13 p 80 See Also unuran cont Examples Create distribution object for standard normal distribution distr lt udnorm Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 Create distribution object for positive normal distribution distr lt udnorm 1b 0 ub Inf and draw a sample gen lt pinvd new distr x lt ur gen 100 udpareto UNU RAN object for Pareto distribution Description Create UNU RAN object for a Pareto distribution of first kind with shape parameters k and a Distribution Pareto of first kind Usage udpareto k a lb k ub Inf Arguments k strictly positive shape and location parameter a strictly positive shape parameter lb lower bound of truncated distribution ub upper bound of truncated distribution udpois 61 Details The Pareto distribution with parameters k and a has density f x ak ta 0 forx gt k k gt 0anda gt 0 The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt Refere
89. mial Usage urbinom n size prob lb ub size Arguments n size of required sample size number of trials one or more prob probability of success on each trial lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Binomial distribution with size n and prob p has density p z ea po forx 0 n The generation algorithm uses guide table based inversion The parameters 1b and ub can be used to generate variates from the Binomial distribution truncated to the interval 1b ub Note This function is a wrapper for the UNU RAN class in R Compared to rbinom urbinom is faster especially for larger sample sizes However in opposition to rbinom vector arguments are ignored i e only the first entry is used 94 urburr Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation unuran for the UNU RAN class and rbinom for the R built in generator Examples Create a sample of size 1000 from the binomial distribution x lt urbinom n 1000 size 10 prob 0 3 urburr UNU RAN Burr random variate generator Description UNU RAN random variate generator for the Burr distribution with shapel and shape2 It also allows
90. n method Advanced Verify rejection method Usage unuran verify hat unr n 1e5 show TRUE Arguments unr an unuran object n sample size integer show whether the result is printed on the console boolean Details UNU RAN is a library of so called black box algorithms For algorithms based on the rejection method this means that hat and squeezes are created automatically during the setup Obviously not all algorithms work for all distribution Then usually the setup fails which is good since then one does not silently obtain a random sample from a distribution other then the requested Although we have tested these algorithms with a lot of distributions including those with extreme properties there is still some minor chance that hat and squeezes are computed without any warn ings but are incorrect i e the inequalities squeeze x lt density x lt hat x are not satisfied for all x This might happen due to serious round off errors for densities with extreme properties e g sharp and narrow peaks But it also might be caused by some incorrect additional information about the distribution given by the user which has not been detected by various checks during the setup If one is unsure about his or her chosen generation method one can check these inequalities Routine unuran verify hat allows to run generator unr and check whether the two inequalities are violated This is done for every point x that is sam
91. nces N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 20 p 574 See Also unuran cont Examples Create distribution object for Pareto distribution distr lt udpareto k 3 a 2 Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udpois UNU RAN object for Poisson distribution Description Create UNU RAN object for a Poisson distribution with parameter lambda Distribution Poisson Usage udpois lambda lb 0 ub Inf 62 udpois Arguments lambda non negative mean lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Poisson distribution has density for x 0 1 2 The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran discr Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and A W Kemp 1992 Univariate Discrete Distributions 2nd edition John Wiley amp Sons Inc New York Chap 4 p 151 See Also unuran discr Examples Create distribution object for Poisson distribution dist lt udpois lambda 2 3 Generate generator object use method DARI gen lt darid new dist Draw a sample of size 10
92. nd pdf are given by their logarithms the dpdf is then the derivative of the logarithm boolean lb lower bound of domain use Inf if unbounded from left numeric ub upper bound of domain use Inf if unbounded from right numeric mode mode of distribution numeric center typical point center of distribution If not given the mode is used numeric area area below pdf used for computing normalization constants if required nu meric name name of distribution string Details Creates an instance of class unuran cont The user is responsible that the given informations are consistent It depends on the chosen method which information must be given are used Note unuran cont new is an alias for new unuran cont Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also unuran cont unuran new unuran Examples Get a distribution object with given pdf domain and mode mypdf lt function x exp x distr lt unuran cont new pdf mypdf islog FALSE 1b 0 ub Inf mode This object can now be used to create an generator object 1 select a method using a Runuran function gen lt pinvd new distr uresolution 1e 12 unuran details 71 2 directly use the UNU RAN string API gen lt unuran
93. ng gen1 lt TRUE use aux urng gen2 lt TRUE set seed 123 x1 lt ur gen1 1e5 set seed 123 x2 lt ur gen2 1e5 cor x1 x2 This feature can be disabled again use aux urng gen1 use aux urng gen1 lt FALSE use aux urng gen2 lt FALSE Notice that TDR cannot simply mixed with an inversion method as the number of URNG per random point differs gen3 lt pinvd new udexp set seed 123 x3 lt ur gen3 1e5 vnrou new cor x1 x3 133 But a trick would do this set seed 123 x3 lt ur gen3 2 1e5 x3 lt x3 seq 1 2 1e5 2 cor x1 x3 or set seed 123 u3 lt runif 2 1e5 u3 lt u3 seg 1 2 1e5 2 x3 lt uq gen3 u3 cor x1 x3 Maybe method AROU is more appropriate gen4 lt unuran new udnorm arou use aux urng gen4 lt TRUE set seed 123 x3 lt ur gen3 1e5 set seed 123 x4 lt ur gen4 1e5 cor x3 x4 vnrou new UNU RAN generator based on Multivariate Naive Ratio Of Uniforms method VNROU Description UNU RAN random variate generator for continuous multivariate distributions with given proba bility density function PDF It is based on the Multivariate Naive Ratio Of Uniforms method VNROU Universal Rejection Method Usage vnrou new dim 1 pdf 11 NULL ur NULL mode NULL center NULL Arguments dim number of dimensions of the distribution integer pdf probability density function R function 11 ur low
94. ng o e a EG Ae a GE Ses 65 Us ioe ee oe eee Shee eae Bese ee td we PEG BSH 66 WOVE gc Qa a eo R E eS AM ee eS E ES ee E ee ee es 67 udweibull 3 4 4 4 4 rias o we HAM REE De ED Se SEER tw EHO EE EES 69 UnUran Class e did Awe EEK OEE e a idos 70 unuran cmy class s sp eee pe nEAaEE AA R 72 unuran cMV NneW p es e c ea a a a a a a a e e a a a T3 unuran cont class o oo ee 74 NUTAD COM MEW pas ci AR RA eA OR RR 75 unuran details oa a TI unuran discr class oe co e ewe eee ae a e a e e e a a 78 unuran discrnew css seagen asane Reer EEEa ea s 80 R topics documented 3 Index unuran distr class a a E E a E e a a a E e a 81 umuran is inversion o sopop ece aone de ae a e EE RE OR AE E O E E t 82 UNUTAN NEW ooge Sh ee eS RR IR E ee EEA RR S 83 unuran packed method o oaoa e 84 unuran verify hat s sc ee ee ee 86 UD 225 eee RUG GB epee a Ate eis EAL Ge Gate dee eae Gea A 87 UG i Aw ead OE GE Ge ee Ee bok ee Poe oa we eee d 89 A 91 UDS dar ma WS a Ad ar a Oe ee a we 92 URDINOM neee e 2 a ety a a a e ky te ws wh ea ee A ed dea 93 A A Bcd GY AC a aie dyes Sh ae A eet eS ss a AC 94 UMCAUCDY 43 2 ti e e A Eg aE O a ee ey 95 WECHE 4 5 da p i BAS EB See os Ba eR Geer be amp OMA Ed HS Bae Swe ES 96 WECHISGi sc oa Ba RA ew a EDR Se ee aE tale ee ee 98 Dd s ee weet baw So oe ae WAR Gee ee eae ee a En he weer ed 99 o bce eh ee BH Se ee SR SAE Re ee ee Re ee 100 UPEXUEME s asg BOE ee oo EA Ro ee eo Re ee Gi
95. niform Random Variate Generation Springer Verlag Berlin Heidelberg See Section 3 2 The Alias Method A J Walker 1977 An efficient method for generating discrete random variables with general distributions ACM Trans Model Comput Simul 3 pp 253 256 See Also ur unuran discr unuran new unuran Examples Create a sample of size 100 for a binomial distribution with size 115 prob 0 5 gen lt dau new pv dbinom 0 115 115 0 5 from 0 x lt ur gen 100 Alternative approach distr lt udbinom size 100 prob 0 3 gen lt daud new distr x lt ur gen 100 dgt new UNU RAN generator based on table guided discrete inversion DGT Description UNU RAN random variate generator for discrete distributions with given probability vector It applies the Guide Table Method for discrete inversion DGT Universal Inversion Method Usage dgt new pv from 1 dgtd new distr Arguments pv vector of non negative numbers need not sum to 1 numeric vector from index of first entry in vector integer distr distribution object S4 object of class unuran discr dgt new 13 Details This function creates an unuran object based on DGT Discrete Guide Table method It can be used to draw samples of a discrete random variate with given probability vector using ur It also allows to compute quantiles by means of uq Vector pv must be postive but need not be normalized i e
96. of the above methods distr class one of the following strings that describes the class of the distribution cont univariate continuous distribution discr univariate discrete distribution 78 unuran discr class cont multivariate continuous distribution In addition the following components may be available area pdf area below density function of the distribution area hat area below hat function for an acceptance rejection method rejection constant rejection constant for an acceptance rejection method It given as the ratio area hat area paf area squeeze area below squeeze function for an acceptance rejection method area hat area squeeze can be used as upper bound for the rejection constant intervals integer that contains the number of subintervals into which the domain of the target distribution is split for constructing a hat function approximating function truncated domain vector of length 2 that contains upper and lower boundary of the computa tional domain that is used for constructing an approximating function Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt See Also unuran Examples Create a generator object distr lt udnorm gen lt tdrd new distr print data about object on console unuran details gen get list with some of these data data lt unuran details gen return list TRUE unuran discr class Class unuran discr for
97. om variate generator Description UNU RAN random variate generator for discrete distributions with given probability vector It applies the Guide Table Method urdgt for discrete inversion or the Alias Urn Method urdau Deprecated Use dgt new or dau new instead Usage urdgt n probvector from 1 urdau n probvector from 0 by 1 l o lt l Arguments n size of required sample probvector vector of non negative numbers need not sum to 1 from number corresponding to the first probability in probvector by from k 1 by is the number corresponding to the k th probability in prob vector Details These routines generate a sample of discrete random variates with given probability vector This vector must be provided by probvector a vector of non negative numbers which need not neces sarily sum up to 1 Method DGT uses a guide table based inversion method Method DAU implements the Alias Urn method Both methods run in constant time i e the marginal sampling times do not depend on the length of the given probability vector Whereas their setup times grow linearly with this length Note urdgt and urdau are very fast for probvector not longer than about 1000 100 urexp Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Sprin
98. on has density 1 2 2 f x oa exp a 2 ax for x 0 and Th otherwise It is the distribution of the ratio of a unit normal variable to an independent standard uniform 0 1 variable The domain of the distribution can be truncated to the interval 1b ub 66 udt Value An object of class unuran cont Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 12 p 63 See Also unuran cont Examples Create distribution object for a slash distribution distr lt udslash Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udt UNU RAN object for Student t distribution Description Create UNU RAN object for a Student t distribution with with df degrees of freedom Distribution t Student Usage udt df lb Inf ub Inf Arguments df degrees of freedom strictly positive Non integer values allowed lb lower bound of truncated distribution ub upper bound of truncated distribution udvg 67 Details The distribution with df y degrees of freedom has density y ADD y y 2 ys f x TOIA 1 2 v for all real x It has mean 0 for y gt 1 and variance a for y gt 2 The domain of t
99. ontinuous multivariate distribution object Description Create a new UNU RAN object for a continuous multivariate distribution The interface might be changed in future releases Do not use unnamed arguments Advanced Continuous Multivariate Distribution Usage unuran cmv new dim 1 pdf NULL 11 NULL ur NULL mode NULL center NULL name NA Arguments dim number of dimensions of the distribution integer pdf probability density function R function 11 ur lower left and upper right vertex of a rectangular domain of the pdf The domain is only set if both vertices are not NULL Otherwise the domain is unbounded by default numeric vectors mode location of the mode numeric vector optional center point in typical region of distribution e g the approximate location of the mode It is used by several methods to locate the main region of the distribution If omitted the mode is implicitly used If the mode is not given either the origin is used numeric vector optional name name of distribution string Details Creates an instance of class unuran cmv The user is responsible that the given informations are consistent It depends on the chosen method which information must be given are used 74 unuran cont class Note unuran cmv new is an alias for new unuran cmv Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J
100. ostive but need not be normalized i e it can be any multiple of a probability mass function The given function must be T_o 5 concave this includes all log concave distributions In addition the algorithm requires the location of the mode If omitted then it is computed by a slow numerical search If the sum over all probabilities is different from 1 then a rough estimate of this sum is required Alternatively one can use function darid new where the object distr of class unuran discr must contain all required information about the distribution Value An object of class unuran Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Gen eration Springer Verlag Berlin Heidelberg See Section 10 2 Tranformed Probability Rejection See Also ur unuran discr unuran new unuran Examples Create a sample of size 100 for a Binomial distribution with 1000 number if observations and probability 0 2 gen lt dari new pmf dbinom 1b 0 ub 1000 size 1000 prob 0 2 x lt ur gen 100 Create a sample from a distribution with PMF p x 1 x 3 x gt 1 Zipf distribution zipf lt function x 1 x 3 gen lt dari new pmf zipf lb 1 ub Inf x lt ur gen 100 Alternative approach dau new 11 distr lt udbinom size 100 prob 0 3 gen lt darid new dist
101. pdf is strictly positive must be connected The center is a point where the pdf is not too small e g a point near the mode of the distribution If the density pdf is given then the algorithm automatically computes the CDF using Gauss Lobatto integration If the cdf is given but not the pdf then the CDF is used instead of the PDF However we found in our experiments that using the PDF is numerically more stable Alternatively one can use function pinvd new where the object distr of class unuran cont must contain all required information about the distribution The algorithm approximates the inverse of the CDF of the distribution by means of Newton inter polation between carefully selected nodes The approxiating functing is thus continuous Argu ment smooth controls whether this function is also differentiable smooth at the nodes Using smooth TRUE requires the pdf of the distribution It results in a higher setup time and memory con sumption Thus using smooth TRUE is not not recommended unless differentiability is important The approximation error is estimated by means of the the u error i e CDE G U U where G denotes the approximation of the inverse CDF The error can be controlled by means of argument uresolution When sampling from truncated distributions with extreme truncation points it is recommended to provide the log density by setting islog TRUE Then the algorithm is numerically more stable The se
102. per bound of truncated distribution Details The F distribution with df1 n and df2 na degrees of freedom has density T ni 2 m2 2 a oe f x Tn 2 P n 2 Un z 1 for x gt 0 The generation algorithm uses fast numerical inversion The parameters 1b and ub can be used to generate variates from the F distribution truncated to the interval 1b ub Note This function is wrapper for the UNU RAN class in R Compared to rf urf is faster especially for larger sample sizes However in opposition to rf vector arguments are ignored i e only the first entry is used Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg urgamma 105 See Also runif and Random seed about random number generation unuran for the UNU RAN class and rf for the R built in generator Examples Create a sample of size 1000 x lt urf n 1000 df1 3 df2 5 urgamma UNU RAN Gamma random variate generator Description UNU RAN random variate generator for the Gamma distribution with parameters shape and scale It also allows sampling from the truncated distribution Special Generator Sampling Function Gamma Usage urgamma n shape scale 1 1b 0 ub Inf Arguments n size of required sample shape strictly positive shape parameter s
103. pled from the hat distribution This includes also those points that are rejected The function counts the occurrences of such evaluations and returns the ratio of this number and the sample size n It is thus a little bit too high since the total number of generated but rejected points is not known Yet it does not provide any information about the magnitude of violation of the inequality If show is TRUE then this routine prints this ratio and some diagnostcs to the console Routine unuran verify hat does not work for algorithms that do not implement a rejection method up 87 Value Ratio of number occurrences where the hat and squeezes violate the inequality and the sample size Note Due to round off errors there might exist a few points where the ratio density x hat x is slightly larger than 1 In our experiments we observed a few cases where this ratio was as large as 1 1078 for some points although we could proof using real numbers instead of floating point numbers that hat and squeeze are computed correctly On the other hand there are cases where due to the limitation of floating point arithmetic it is not possible to sample from the target distribution at all The Gamma distribution with extremely small shape parameter say 0 0001 is such an example Then the continuous Gamma distribution degenerates to a point distribution with only a few points with significant mass Author s Josef Leydold and Wolfgang HWormann
104. r x lt ur gen 100 dau new UNU RAN generator based on the Alias method DAU Description UNU RAN random variate generator for discrete distributions with given probability vector It applies the Alias Urn method DAU Universal Patchwork Method Usage dau new pv from 1 daud new distr Arguments pv vector of non negative numbers need not sum to 1 numeric vector from index of first entry in vector integer distr distribution object S4 object of class unuran discr Details This function creates a unuran object based on DAU Discrete Alias Urn method It can be used to draw samples of a discrete random variate with given probability vector using ur Vector pv must be postive but need not be normalized i e it can be any multiple of a probability vector The method runs fast in constant time i e marginal sampling times do not depend on the length of the given probability vector Whereas their setup times grow linearly with this length Notice that the range of random variates is from from length pv 1 Alternatively one can use function daud new where the object distr of class unuran discr must contain all required information about the distribution Value An object of class unuran Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt 12 dgt new References W H ormann J Leydold and G Derflinger 2004 Automatic Nonu
105. ran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also unuran cont unuran discr unuran udbeta 31 Examples Create an UNU RAN distribution object for standard Gaussian and evaluate density for some points distr lt udnorm ud distr 1 5 ud distr 3 3 Create an UNU RAN generator object for standard Gaussian and evaluate density of underyling distribution gen lt tdrd new udnorm ud gen 1 5 ud gen 3 3 udbeta UNU RAN object for Beta distribution Description Create UNU RAN object for a Beta distribution with with parameters shape1 and shape2 Distribution Beta Usage udbeta shapel shape2 lb 0 ub 1 Arguments shapel shape2 positive shape parameters of the Beta distribution lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Beta distribution with parameters shape1 a and shape2 b has density FE 5 e 2 fora gt 0 b gt Oand0 lt 2 lt 1 The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont 32 udbinom Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1995 Continuous Univariate Distributions Volume 2 2nd edition John W
106. rator for the Chi Squared x distribution with df degrees of free dom It also allows sampling from the truncated distribution Special Generator Sampling Function Chi squared Usage urchisq n df 1b 0 ub Inf Arguments n size of required sample df degrees of freedom strictly positive but can be non integer lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Chi squared distribution with df n gt 0 degrees of freedom has density 1 22D n 2 n 2 1 77 2 for x gt 0 The generation algorithm uses fast numerical inversion The parameters lb and ub can be used to generate variates from the Chi squared distribution truncated to the interval 1b ub Note This function is wrapper for the UNU RAN class in R Compared to rchisq urchisq is faster especially for larger sample sizes However in opposition to rchisq vector arguments are ignored i e only the first entry is used Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg urdgt 99 See Also runif and Random seed about random number generation unuran for the UNU RAN class and rchisq for the R built in generator Examples Create a sample of size 1000 x lt urchisq n 1000 df 3 urdgt UNU RAN discrete rand
107. required sample shapel shape2 positive shape parameters of the Beta distribution lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Beta distribution with parameters shape1 a and shape2 b has density f z 5 mea fora gt 0 6 gt Oand0 lt 2 lt 1 The generation algorithm uses fast numerical inversion The parameters 1b and ub can be used to generate variates from the Beta distribution truncated to the interval 1b ub Note This function is wrapper for the UNU RAN class in R Compared to rbeta urbeta is faster espe cially for larger sample sizes However in opposition to rbeta vector arguments are ignored i e only the first entry is used Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg urbinom 93 See Also runif and Random seed about random number generation unuran for the UNU RAN class and rbeta for the R built in generator Examples Create a sample of size 1000 x lt urbeta n 1000 shapel 2 shape2 5 urbinom UNU RAN Binomial random variate generator Description UNU RAN random variate generator for the Binomial distribution with parameters size and prob It also allows sampling from the truncated distribution Special Generator Sampling Function Bino
108. rface gen lt unuran new normal hinv uq gen 975 ug gen c 0 025 0 975 Compute quantiles of user defined distributio using method HINV using advanced interface cdf lt function x 1 exp x pdf lt function x exp x dist lt new unuran cont cdf cdf pdf pdf 1lb 0 ub Inf gen lt unuran new dist hinv u_resolution 1 e 12 uq gen seq 1 0 5 ur Sample from a distribution specified by a unuran object Description Get random sample from a unuran object in package Runuran Universal Sampling Function Usage ur unr n 1 unuran sample unr n 1 Arguments unr a unuran object n sample size Note unuran sample is just an older longer name for ur Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt See Also runif and Random seed about random number generation unuran for the UNU RAN class Examples Draw random sample of size 10 from normal distribution using HH method TDR unr lt unuran new normal tdr x lt ur unr n 10 92 urbeta urbeta UNU RAN Beta random variate generator Description UNU RAN random variate generator for the Beta distribution with parameters shape1 and shape2 It also allows sampling from the truncated distribution Special Generator Sampling Function Beta Usage urbeta n shapel shape2 lb 0 ub 1 Arguments n size of
109. rkov Chain Monte Carlo Procedures for Sampling from Multivariate Distributions Research Report Series Department of Statistics and Mathematics Nr 27 December 2005 Department of Statistics and Mathematics Wien Wirtschaftsuniv 2005 http epub wu ac at dyn virlib wp showentry ID epub wu 01_ 8cb See Also ur unuran new unuran Examples Create a sample of size 100 for a Gaussian distribution mvpdf lt function x exp sum x 2 gen lt hitro new dim 2 pdf mvpdf x lt ur gen 100 Use mode of Gaussian distribution Reduce auto correlation by thinning and burn in mode at 0 0 thinning factor 3 HH only every 3rd vector in the sequence is returned burn in of length 1000 HH the first 10 vectors in the sequence are discarded mvpdf lt function x exp sum x 2 gen lt hitro new dim 2 pdf mvpdf mode c thinning 3 burnin 1000 x lt ur gen 100 Gaussian distribution restricted to the rectangle 1 21x 1 2 don t forget to provide a starting point using center mvpdf lt function x exp sum x 2 gen lt hitro new dim 2 pdf mvpdf center c 1 1 1 1 ll c 1 1 ur c 2 2 x lt ur gen 100 16 itdr new itdr new UNU RAN generator based on Inverse Transformed Density Rejection ITDR Description UNU RAN random variate generator for continuous distributions with given probability density function PDF It is based on the Inver
110. s can be created by calls of the form new unuran distribution method distribution A character string that describes the target distribution see UNU RAN User Manual or one of the S4 classes unuran cont unuran discr or unuran cmv that holds information about the distribution method A character string that describes the chosen generation method see UNU RAN User Manual If omitted method auto automatic is used See unuran new for short introduction and examples for this interface unuran class 71 Methods The class unuran provides the following methods for handling objects ur signature object unuran Get a random sample from the stream object r signature object unuran Same as ur initialize signature Object unuran Initialize unuran object For Internal usage only print signature x unuran Print info about unuran object show signature x unuran Same as print Warning unuran objects cannot be saved and restored in later R sessions nor is it possible to copy such objects to different nodes in a computer cluster However unuran objects for some generation methods can be packed see unuran packed Then these objects can be handled like any other R object and thus saved and restored All other objects must be newly created in a new R session Using a restored object does not work as the unuran is then broken Note The interface has been changed compared to the
111. sampling from the truncated distribution Special Generator Sampling Function Burr Usage urburr n a b 1b 0 ub Inf Arguments n size of required sample a b positive shape parameters of the Burr distribution lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Burr distribution with parameters a and b has density f x a b 1 2 7 14a for x gt 0 a gt 1andb gt 2 The generation algorithm uses transformed density rejection TDR The parameters 1b and ub can be used to generate variates from the Burr distribution truncated to the interval 1b ub urcauchy 95 Note This function is a wrapper for the UNU RAN class in R Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation and unuran for the UNU RAN class Examples Create a sample of size 1000 x lt urburr n 1000 a 2 b 3 urcauchy UNU RAN Cauchy random variate generator Description UNU RAN random variate generator for the Cauchy distribution with location parameter location and scale parameter scale It also allows sampling from the truncated distribution Special Generator Sampling Function Cauchy Usage urcauchy n location 0
112. sampling from the truncated distribution Special Generator Sampling Function Geometric Usage urgeom n prob lb 0 ub Inf Arguments n size of required sample prob probability of success in each trial lt prob lt 1 lb lower bound of truncated distribution ub upper bound of truncated distribution urgig 107 Details The Geometric distribution with prob p has density p x p 1 p forx 0 1 2 0 lt p lt l The generation algorithm uses guide table based inversion for p gt 0 02 and method DARI other wise The parameters 1b and ub can be used to generate variates from the Geometric distribution truncated to the interval 1b ub Note This function is a wrapper for the UNU RAN class in R Compared to rgeom urgeom is faster especially for larger sample sizes However in opposition to rgeom vector arguments are ignored 1 e only the first entry is used Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation unuran for the UNU RAN class and rgeom for the R built in generator Examples Create a sample of size 1000 x lt urgeom n 1000 prob 0 2 urgig UNU RAN Generalized Inverse Gaussian Distribution variate genera tor Description
113. se Transformed Density Rejection method ITDR Universal Rejection Method Usage itdr new pdf dpdf lb ub pole islog FALSE itdrd new distr Arguments pdf probability density function R function dpdf derivative of pdf R function pole pole of distribution numeric lb lower bound of domain use Inf if unbounded from left numeric ub upper bound of domain use Inf if unbounded from right numeric islog whether pdf is given as log density the dpdf must then be the derivative of the log density boolean optional arguments for pdf distr distribution object S4 object of class unuran cont Details This function creates a unuran object based on ITDR Inverse Transformed Density Rejection It can be used to draw samples of a continuous random variate with given probability density function using ur The density pdf must be positive but need not be normalized i e it can be any multiple of a density function The algorithm is especially designed for distributions with unbounded densities Thus the algorithm needs the position of the pole Moreover the given function must be monotone on its domain The derivative dpdf is essential Numerical derivation does not work as it results in serious round off errors Alternatively one can use function itdrd new where the object distr of class unuran cont must contain all required information about the distribution The setup time of th
114. sed to generate variates from the Normal distribution truncated to the interval 1b ub Note This function is a wrapper for the UNU RAN class in R Compared to rnorm urnorm is faster especially for larger sample sizes However in opposition to rnorm vector arguments are ignored i e only the first entry is used Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg 120 urpareto See Also runif and Random seed about random number generation unuran for the UNU RAN class and rnorm for the R built in normal random variate generator Examples Create a sample of size 1000 x lt urnorm n 1000 urpareto UNU RAN Pareto random variate generator Description UNU RAN random variate generator for the Pareto distribution of first kind with shape parameters k and a It also allows sampling from the truncated distribution Special Generator Sampling Function Pareto of first kind Usage urpareto n k a lb k ub Inf Arguments n size of required sample k strictly positive shape and location parameter a strictly positive shape parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Pareto distribution with parameters k and a has density Fla ak q 0 1 forx gt
115. sed when a rejection has occurred see below for details This allows to keep two streams of random variates almost synchronized This is in particular necessary for variance reduction methods like common or antithetic random variates Advanced Use auxiliary URNG for rejection method Usage S4 method for signature unuran use aux urng unr use aux urng unr lt value set aux seed seed Arguments unr a unuran generator object value TRUE when an auxiliary URNG is used FALSE when no auxiliary URNG is used the default seed seed for the auxiliary URNG Details Variance reduction techniques like common or antithetic random variates require correlated streams of non uniform random variates Such streams can be easily created by means of the inversion method using the same source of uniform random numbers URNs However the quantile function inverse CDF or even the CDF often is not available in closed form and thus numerical method are required that are expensive or only return approximate random numbers or both On the other hand two streams of non uniformly distributed random variates are completely un correlated when the acceptance rejection method is used Then the two streams run out of sync when the first rejection occurs Schmeiser and Kachitvichyanukul however have shown that this problem can be overcome when the proposal point is generated by inversion and a fixed number k of URNs is used for generatin
116. set seed ars new 7 Warning unuran objects cannot be saved and restored in later R sessions nor is it possible to copy such objects to different nodes in a computer cluster However unuran objects for some generation methods can be packed see unuran packed Then these objects can be handled like any other R object and thus saved and restored All other objects must be newly created in a new R session Using a restored object does not work as the unuran object is then broken Note The interface has been changed compared to the DSC 2003 paper Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References J Leydold and W H ormann 2000 2008 UNU RAN User Manual see http statmath wu ac at unuran W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg G Tirler and J Leydold 2003 Automatic Nonuniform Random Variate Generation in R In K Hornik and F Leisch Proceedings of the 3rd International Workshop on Distributed Statistical Computing DSC 2003 March 20 22 Vienna Austria See Also All objects are implemented as respective S4 classes unuran unuran distr unuran cont unuran discr unuran See Runuran special generators for an overview of special generators and Runuran distributions for a list of ready to use distributions suitable for the automatic methods ars new UNU
117. sses is reached The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran discr Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and A W Kemp 1992 Univariate Discrete Distributions 2nd edition John Wiley amp Sons Inc New York Sect 5 1 p 200 See Also unuran discr udnorm 59 Examples Create distribution object for Negative Binomial distribution dist lt udnbinom size 100 prob 0 33 Generate generator object use method DARI gen lt darid new dist Draw a sample of size 100 x lt ur gen 100 udnorm UNU RAN object for Normal distribution Description Create UNU RAN object for a Normal Gaussian distribution with mean equal to mean and stan dard deviation to sd Distribution Normal Gaussian Usage udnorm mean 0 sd 1 lb Inf ub Inf Arguments mean mean of distribution sd standard deviation lb lower bound of truncated distribution ub upper bound of truncated distribution Details The normal distribution with mean y and standard deviation has density 1 210 au 20 f x where u is the mean of the distribution and the standard deviation The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Author s Josef Leydold and Wolfgang H or
118. ssumes the default value of 1 The Rayleigh distribution with scale parameter scale has density T xp al 2 sigma f x E zT sigma for x gt 0 and o gt 0 The generation algorithm uses fast numerical inversion The parameters lb and ub can be used to generate variates from the Rayleigh distribution truncated to the interval 1b ub Note This function is a wrapper for the UNU RAN class in R Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 18 p 456 126 urt See Also runif and Random seed about random number generation and unuran for the UNU RAN class Examples HH Create a sample of size 1000 from Rayleigh distribution with scale 1 x lt urrayleigh n 1000 scale 1 urt UNU RAN Student t random variate generator Description UNU RAN random variate generator for the Student t distribution with with df degrees of freedom It also allows sampling from the truncated distribution Special Generator Sampling Function t Student Usage urt n df lb Inf ub Inf Arguments n size of required sample df degrees of freedom gt 0 maybe non integ
119. stribution respectively Usage ud obj x islog FALSE Arguments obj one of e a distribution object of class unuran cont that contains the PDF or e a distribution object of class unuran discr that contains the PMF or e a generator object class unuran that contains the PDF and PMF resp x vector of x values numeric islog if TRUE the log density is returnd boolean Details The routine evaluates the probability density function of a distribution stored in a UNU RAN dis tribution object or UNU RAN generator object If islog is TRUE then the logarithm of the density is returned If the PDF or its respective logarithm is not available in the object then NA is returned and a warning is thrown Note when the log density is not given explicitly by setting islog TRUE in the corresponding routing like unuran cont new or in an Runuran built in distribution then NA is returned even if the density is given Important Routine ud just evaluates the density function that is stored in obj It ignores the boundaries of the domain of the distribution i e it does not return outside the domain unless the implementation of the PDF handles this case correctly This behavior is in particular important when Runuran built in distributions are truncated by explicitly setting the domain boundaries Note The generator object must not be packed see unuran packed Author s Josef Leydold and Wolfgang H ormann lt unu
120. t flexible access to UNU RAN It requires three steps 1 Create a unuran distr object that contains all required information about the target distribu tion We have three types of distributions Function Type of distribution unuran cont new Continuous distributions unuran discr new discrete distributions unuran cmv new multivariate continuous distributions The functions from section Distribution creates such objects for particular distributions 2 Choose a generation method and create a unuran object using function unuran new This function takes two argument the distribution object created in Step 1 and a string that contains the chosen UNU RAN method and optional some parameters to adjust this method to the given target distribution We refer to the UNU RAN for more details on this method string 3 Use this object to draw samples from the target distribution using ur or uq Function ur draw sample uq compute quantile inverse CDF unuran details show unuran object Density and distribution function UNU RAN distribution objects and generator objects may also be used to compute density and distribution function for a given distribution by means of ud and up Uniform random numbers All UNU RAN methods use the R built in random number generator as source of pseudo random numbers Thus the generated samples depend on the state Random seed and can be controlled by the R functions RNGkind and
121. tandard deviation of the distribution on the log scale lb lower bound of truncated distribution ub upper bound of truncated distribution Details The log normal distribution has density 7 exp log x 1 2sigma where u is the mean and the standard deviation of the logarithm The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 14 p 207 See Also unuran cont Examples Create distribution object for log normal distribution distr lt udlnorm Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udlogarithmic 53 udlogarithmic UNU RAN object for Logarithmic distribution Description Create UNU RAN object for a Logarithmic distribution with shape parameter shape Distribution Logarithmic Usage udlogarithmic shape lb 1 ub Inf Arguments shape shape parameter Must be between 0 and 1 lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Logarithmic distribution with parameters shape 0 has density f a log
122. terval 1b ub Note This function is wrapper for the UNU RAN class in R Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg N L Johnson S Kotz and N Balakrishnan 1995 Continuous Univariate Distributions Volume 2 2nd edition John Wiley amp Sons Inc New York Chap 22 p 2 See Also runif and Random seed about random number generation and unuran for the UNU RAN class Examples Create a sample of size 1000 x lt urextremel n 1000 urextremell UNU RAN Extreme value type II Frechet type random variate gen erator Description UNU RAN random variate generator for the Extreme value type II Frechet type distribution with shape parameter shape location parameter location and scale parameter scale It also allows sampling from the truncated distribution Special Generator Sampling Function Frechet extreme value type II urextremell 103 Usage urextremell n shape location 0 scale 1 lb location ub Inf Arguments n size of required sample shape strictly positive shape parameter location location parameter scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details If location or scale are not specified they assume the
123. tion Il ur lower left and upper right vertex of a rectangular domain of the pdf The domain is only set if both vertices are not NULL Otherwise the domain is unbounded by default numeric vectors mode location of the mode numeric vector optional center point in typical region of distribution e g the approximate location of the mode It is used by several methods to locate the main region of the distribution If omitted the mode is implicitly used If the mode is not given either the origin is used numeric vector optional name name of distribution string The user is responsible that the given informations are consistent It depends on the chosen method which information must be given are used It is important that the mode is contained in the closure of the domain Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References J Leydold and W H ormann 2000 2007 UNU RAN User Manual see http statmath wu ac at unuran See Also unuran cmv new unuran new unuran unuran cmv new 73 Examples Create distribution with given PDF mvpdf lt function x exp sum x 2 mvdist lt new unuran cmv dim 2 pdf mvpdf HH Restrict domain to rectangle 0 1 x 0 1 and set mode to 0 0 mvpdf lt function x exp sum x 2 mvdist lt new unuran cmv dim 2 pdf mvpdf 11 c ur c 1 1 mode c 0 0 unuran cmv new Create a UNU RAN c
124. to of first kind Planck Powerexponential Subbotin Rayleigh t Student Triangular Weibull Distribution Binomial Geometric Hypergeometric Logarithmic Negative Binomial Poisson Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt See Also Runuran package Runuran distributions Examples draw a sample of size 100 from a gamma distribution with shape para x lt urgamma n 100 shape 5 meter 5 26 srou new draw a sample of size 100 from a half normal distribution x lt urnorm n 100 lb 0 ub Inf srou new UNU RAN generator based on Simple Ratio Of Uniforms Method SROU Description UNU RAN random variate generator for continuous distributions with given probability density function PDF It is based on the Simple Ratio Of Uniforms Method SROU Universal Rejection Method Usage srou new pdf lb ub mode area islog FALSE r 1 sroud new distr r 1 Arguments pdf probability density function R function lb lower bound of domain use Inf if unbounded from left numeric ub upper bound of domain use Inf if unbounded from right numeric mode location of the mode numeric area area below pdf numeric islog whether pdf is given as log density the dpdf must then be the derivative of the log density boolean optional arguments for pdf distr distribution object S4 object of class unuran cont r adjust algorithm to heavy tail
125. triang 127 urweibull 128 vnrou new 133 Topic methods unuran packed method 84 use aux urng method 130 Random seed 6 84 91 93 97 99 101 103 105 108 110 113 115 118 120 124 126 129 ars new 5 7 28 29 arsd new ars new 7 dari new 5 9 darid new dari new 9 dau new 5 11 99 100 daud new dau new 11 dgt new 5 12 99 dgtd new dgt new 12 gamma 41 63 105 124 hitro new 5 14 initialize unuran method unuran class 70 initialize unuran cmv method unuran cmv class 72 initialize unuran cont method unuran cont class 74 initialize unuran discr method unuran discr class 78 initialize unuran distr method unuran distr class 81 itdr new 5 16 itdrd new itdr new 16 mixt new 17 pinv new 5 19 85 88 pinvd new pinv new 19 print unuran method unuran class 70 print unuran cmv method unuran cmv class 72 print unuran cont method unuran cont class 74 print unuran discr method unuran discr class 78 INDEX print unuran distr method unuran distr class 81 rbeta 93 rbinom 94 rcauchy 96 rchisq 99 rexp 101 rf 105 rgamma 106 rgeom 107 rhyper 110 111 rlnorm 113 rlogis 116 rnbinom 718 RNGkind 6 rnorm 120 rpois 1 23 rt 127 runif 84 91 93 97 99 101 103 105 108 110 113 115 118 120 124 126 129 Runuran Runuran package 4 Runuran package 4 Runuran distributions 6 7 22 25 Runuran special
126. tribution Description Create UNU RAN object for a Rayleigh distribution with scale parameter scale Distribution Rayleigh Usage udrayleigh scale 1 1b 0 ub Inf Arguments scale strictly positive scale parameter lb lower bound of truncated distribution ub upper bound of truncated distribution Details The Rayleigh distribution with scale parameter scale has density 1 x 2 f e cexp sigma 2 sigma for x gt 0and y gt 0 The domain of the distribution can be truncated to the interval 1b ub Value An object of class unuran cont Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt udslash 65 References N L Johnson S Kotz and N Balakrishnan 1994 Continuous Univariate Distributions Volume 1 2nd edition John Wiley amp Sons Inc New York Chap 18 p 456 See Also unuran cont Examples Create distribution object for standard Rayleigh distribution distr lt udrayleigh Generate generator object use method PINV inversion gen lt pinvd new distr Draw a sample of size 100 x lt ur gen 100 udslash UNU RAN object for Slash distribution Description Create UNU RAN object for a Slash distribution Distribution Slash Usage udslash 1b Inf ub Inf Arguments lb lower bound of truncated distribution ub upper bound of truncated distribution Details The slash distributi
127. tup time of this method depends on the given PDF whereas its marginal generation times are independent of the target distribution pinv new 21 Value An object of class unuran Remark Using function up generator objects that implement method PINV may also be used to approxi mate the cumulative distribution function of the given distribution when only the density is given The approximation error is about one tenth of the requested uresolution Author s Josef Leydold and Wolfgang HWormann lt unuran statmath wu ac at gt References G Derflinger W H ormann and J Leydold 2010 Random variate generation by numerical inversion when only the density is known ACM Trans Model Comput Simul 20 4 18 See Also ur ug up Unuran cont unuran new unuran Examples Create a sample of size 100 for a Gaussian distribution pdf lt function x exp 5 x 2 gen lt pinv new pdf pdf lb Inf ub Inf x lt ur gen 100 Create a sample of size 100 for a Gaussian distribution use logPDF logpdf lt function x 0 5xx 2 gen lt pinv new pdf logpdf islog TRUE lb Inf ub Inf x lt ur gen 100 Draw sample from Gaussian distribution with mean 1 and standard deviation 2 Use dnorm gen lt pinv new pdf dnorm lb Inf ub Inf mean 1 sd 2 x lt ur gen 100 Draw a sample from a truncated Gaussian distribution on domain 2 Inf gen lt pinv new pdf
128. ture is enabled It auxiliary URNs are not supported at all for object unr then use aux urng unr returns NA The replacement method use aux urng unr lt TRUE enables this feature for generator unr It can be disabled by means of use aux urng unr lt FALSE One gets an error if this feature is not supported at all The seed of the auxiliary uniform random number generator can be set by means of set aux seed seed The auxiliary generator is a combined multiple recursive generator MRG31k3p by L Ecuyer and Touzin and is built into package Runuran Currently it cannot be replaced by some other generator Value use aux urng returns TRUE if using the auxiliary generator is enabled FALSE it is disabled and NA if this feature does not exist at all set aux seed returns NULL invisibly Methods Currently the following UNU RAN methods support this feature Currently the last four methods are only available via unuran new see the UNU RAN manual for more details method name Runuran call URN per variate tdr ps tdr new 2 arou ia 1 tabl ia false 2 tdr gw 2 tdr ia 1 inversion 1 Note Using an auxiliary uniform random number generator generator is only useful if the rejection con stant is close to 1 132 use aux urng method References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Sect 8 4 2 Spring
129. u ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg Section 11 1 4 See Also ur unuran new unuran Examples Create a sample of size 100 for a Gaussian distribution mvpdf lt function x exp sum x 2 gen lt vnrou new dim 2 pdf mvpdf x lt ur gen 100 Use mode of Gaussian distribution to accelerate set up mvpdf lt function x exp sum x 2 gen lt vnrou new dim 2 pdf mvpdf mode c 0 0 x lt ur gen 100 Gaussian distribution restricted to the rectangle 1 21x 1 2 don t forget to provide a point inside domain using center mvpdf lt function x exp sum x 2 gen lt vnrou new dim 2 pdf mvpdf ll c 1 1 ur c 2 2 center c 1 5 1 5 x lt ur gen 100 Index Topic Classes unuran class 70 unuran cmv class 72 unuran cont class 74 unuran discr class 78 unuran distr class 81 Topic datagen ars new 7 dari new 9 dau new 11 dgt new 12 hitro new 14 itdr new 16 mixt new 17 pinv new 19 Runuran package 4 Runuran distributions 22 Runuran special generators 24 srou new 26 tdr new 27 unuran class 70 unuran cmv class 72 unuran cmv new 73 unuran cont class 74 unuran cont new 75 unuran details 77 unuran discr class 78 unuran discr new 80 unuran distr class 81 unuran is inversion 82 unuran new 83 unuran pac
130. udes mixtures of distributions Thus mixtures can also be defined recursively Moreover none of these components must be packed see unuran packed Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt pinv new 19 References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Section 2 3 Composition See Also ur ug unuran new unuran Examples Create a mixture of an Exponential and a Half normal distribution unr1 lt unuran new udnorm 1b Inf ub 0 unr2 lt unuran new udexp mix lt mixt new c 1 1 c unr1 unr2 x lt ur mix 100 Now use inversion method It is important that 1 we use a inversion for each component 2 the domains to not overlap 3 the components are ordered with respect to their domains unr1 lt pinvd new udnorm 1b Inf ub 0 unr2 lt pinvd new udexp mix lt mixt new c 1 1 c unr1 unr2 inversion TRUE x lt ur mix 100 We also can compute the inverse distribution function x lt uq mix 0 90 Create a mixture of Exponential and Geometric distrbutions unr1 lt unuran new udexp unr2 lt unuran new udgeom 0 7 mix lt mixt new c 0 6 0 4 c unr1 unr2 x lt ur mix 100 pinv new UNU RAN generator based on Polynomial interpolation of INVerse CDF PINV Description UNU RAN random var
131. uments n size of required sample a b left and right boundary of domain m mode of distribution lb lower bound of truncated distribution ub upper bound of truncated distribution 128 urweibull Details The Triangular distribution with domain a b and mode m has a density proportional to f z x a m a fora lt x lt m and f z b x b m form lt x lt b The generation algorithm uses fast numerical inversion The parameters 1b and ub can be used to generate variates from the Triangular distribution truncated to the interval 1b ub Note This function is a wrapper for the UNU RAN class in R Author s Josef Leydold and Wolfgang H ormann lt unuran statmath wu ac at gt References W H ormann J Leydold and G Derflinger 2004 Automatic Nonuniform Random Variate Generation Springer Verlag Berlin Heidelberg See Also runif and Random seed about random number generation and unuran for the UNU RAN class Examples Create a sample of size 1000 x lt urtriang n 1000 a 1 m 0 b 2 urweibull UNU RAN Weibull random variate generator Description UNU RAN random variate generator for the Weibull distribution with with parameters shape and scale It also allows sampling from the truncated distribution Special Generator Sampling Function Weibull Usage urweibull n shape scale 1 l1b 0 ub Inf urweibull 129 Arguments n size of required sample sh
132. version method should be used boolean Details Given a set of probability density functions p 1 pn x called the mixture components and weights w1 Wn such that w gt 0 and w 1 the sum q x ye wi pi 2 1s called the mixture density Function mixt new creates an unuran object for a finite mixture of continuous or discrete univariate distributions It can be used to draw samples of a continuous random variate using ur The weights prob must be a vector of non negative numbers not all equal to 0 but need not sum to 1 comp is a list of unuran generator objects Each of which must sample from a continuous or discrete univariate distribution If inversion is TRUE then the inversion method is used for sampling from the mixture distribution However the following conditions must be satisfied e Each component unuran object must use implement an inversion method i e the quantile funtion uq must work e The domains of the components must not overlapping e The components must be order with respect to their domains If one of these conditions is violated then initialization of the mixture object fails The setup time is fast whereas its marginal generation times strongly depend on the average gener ation times of its components Value An object of class unuran Note Each component in comp must correspond to a continuous or discrete univariate distribution In particular this also incl
133. xp sqrt 1 x 2 restricted to domain 1 2 We first have to define functions that return the log density and its derivative respectively We also could use the density itself lf lt function x sqrt 1 x 2 dlf lt function x x sqrt 1 x 2 Next create the continuous distribution object d lt unuran cont new pdf 1f dpdf dl1f islog TRUE 1b 1 ub 2 Create unuran object We choose method TDR with immediate acceptance IA and parameter c 0 gen lt unuran new distr d method tdr variant_ia c Now we can use this object to draw the sample Of course we can repeat this step as often as required ur gen 10 Here is some information about our generator object unuran details gen unuran packed method Pack unuran object Description Pack unuran object in package Runuran and report its status packed unpacked Packed unuran objects can be saved and loaded or sent to other nodes in a computer cluster which is not possible for unpacked object FIXME Usage S4 method for signature unuran unuran packed unr unuran packed unr lt value unuran packed method 85 Arguments unr a unuran object value TRUE to pack the object Details A unuran object contains a pointer to an external object in library UNU RAN Thus it cannot be saved and restored in later R sessions nor is it possible to copy such an object to different nodes in a computer
134. yleigh 25 125 urt 25 126 urtriang 25 127 urweibull 25 128 use aux urng use aux urng method 130 use aux urng unuran method use aux urng method 130 use aux urng method 130 use aux urng lt use aux urng method 130 use aux urng lt unuran method use aux urng method 130 use aux urng lt method use aux urng method 130 vnrou new 6 133
Download Pdf Manuals
Related Search
Related Contents
Velleman KSR2 toy Enfora ® EDG1228 Quad-Band SA-EL - User Manual PayPal Website Payments Pro - 2009 Payflow Edition Developer's Guide Adhere CPM.fF - West Penetone Canada Samsung SMX-K40BP Priručnik za korisnike Black & Decker BISTRO BLD100 User's Manual Basic Patrol Management System (PMS) 7.x User Manual Insignia NS-PDP50HD-09 Flat Panel Television User Manual PDFダウンロード - 一般社団法人 日本冷凍空調工業会 GPS-DR - Digital Instruments S.r.l. Copyright © All rights reserved.
Failed to retrieve file