Description Usage Arguments Details Value Author(s) Examples
Density function and random number generation for the Dirichlet distribution
1 | rdirichlet(n, alpha)
|
n |
number of random observations to draw |
alpha |
the Dirichlet distribution's parameters. Can be a vector (one set of parameters for all observations) or a matrix (a different set of parameters for each observation), see “Details” |
The Dirichlet distribution is a multidimensional generalization of the Beta distribution where each dimension is governed by an alpha-parameter. Formally this is
D(α)=[Γ(∑α)/∏Γ(α)]∏ y^(α-1)
Usually, alpha
is a vector thus the same parameters will be used for all observations.
If alpha
is a matrix, a complete set of alpha-parameters must be supplied for each observation.
returns a matrix with random numbers according to the supplied alpha vector or matrix.
Chong Wu
1 2 | X1 <- rdirichlet(100, c(5, 5, 10))
X1
|
Loading required package: vegan
Loading required package: permute
Loading required package: lattice
This is vegan 2.5-4
Loading required package: ape
Loading required package: aSPU
Loading required package: gee
Loading required package: MASS
Loading required package: mvtnorm
Loading required package: fields
Loading required package: spam
Loading required package: dotCall64
Loading required package: grid
Spam version 2.2-2 (2019-03-07) is loaded.
Type 'help( Spam)' or 'demo( spam)' for a short introduction
and overview of this package.
Help for individual functions is also obtained by adding the
suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
Attaching package: 'spam'
The following objects are masked from 'package:base':
backsolve, forwardsolve
Loading required package: maps
See https://github.com/NCAR/Fields for
an extensive vignette, other supplements and source code
Loading required package: matrixStats
Loading required package: cluster
Attaching package: 'cluster'
The following object is masked from 'package:maps':
votes.repub
[,1] [,2] [,3]
[1,] 0.29105184 0.24806740 0.4608808
[2,] 0.25382229 0.33254543 0.4136323
[3,] 0.11365039 0.57758880 0.3087608
[4,] 0.25860573 0.40678402 0.3346103
[5,] 0.12746048 0.26510768 0.6074318
[6,] 0.26751905 0.27356930 0.4589117
[7,] 0.31176683 0.30055708 0.3876761
[8,] 0.21664021 0.16004899 0.6233108
[9,] 0.31093869 0.30607414 0.3829872
[10,] 0.35615739 0.32370583 0.3201368
[11,] 0.11284317 0.39429438 0.4928624
[12,] 0.13753828 0.25636807 0.6060937
[13,] 0.33833881 0.22959871 0.4320625
[14,] 0.30661004 0.44370568 0.2496843
[15,] 0.43039055 0.11684270 0.4527667
[16,] 0.25165503 0.29395678 0.4543882
[17,] 0.19939113 0.12156608 0.6790428
[18,] 0.39172161 0.35856373 0.2497147
[19,] 0.26490581 0.27751978 0.4575744
[20,] 0.43525198 0.19792406 0.3668240
[21,] 0.29484520 0.41945323 0.2857016
[22,] 0.41528304 0.06847855 0.5162384
[23,] 0.35908524 0.32313296 0.3177818
[24,] 0.20850325 0.32757231 0.4639244
[25,] 0.36970308 0.22289124 0.4074057
[26,] 0.22034737 0.31856185 0.4610908
[27,] 0.30277456 0.14689051 0.5503349
[28,] 0.18405935 0.33721352 0.4787271
[29,] 0.42371140 0.26275292 0.3135357
[30,] 0.21123281 0.19619178 0.5925754
[31,] 0.08900358 0.35445936 0.5565371
[32,] 0.21268466 0.23258089 0.5547345
[33,] 0.25741906 0.13555578 0.6070252
[34,] 0.21032519 0.13018204 0.6594928
[35,] 0.21662694 0.16256778 0.6208053
[36,] 0.24368849 0.19508822 0.5612233
[37,] 0.16601711 0.19571871 0.6382642
[38,] 0.22441511 0.19064478 0.5849401
[39,] 0.28591009 0.34904109 0.3650488
[40,] 0.32171421 0.21767947 0.4606063
[41,] 0.18372713 0.14384564 0.6724272
[42,] 0.27299559 0.26801278 0.4589916
[43,] 0.19577170 0.33440854 0.4698198
[44,] 0.28540894 0.28218834 0.4324027
[45,] 0.26129145 0.15253126 0.5861773
[46,] 0.33044326 0.22850552 0.4410512
[47,] 0.17690680 0.44385360 0.3792396
[48,] 0.21753701 0.30270723 0.4797558
[49,] 0.21473043 0.33983482 0.4454348
[50,] 0.19907245 0.43788822 0.3630393
[51,] 0.26771481 0.23118532 0.5010999
[52,] 0.20343841 0.21889661 0.5776650
[53,] 0.28493347 0.17253773 0.5425288
[54,] 0.19705209 0.37115920 0.4317887
[55,] 0.10464306 0.15683067 0.7385263
[56,] 0.06269919 0.32598628 0.6113145
[57,] 0.22658491 0.21825749 0.5551576
[58,] 0.36851602 0.18977634 0.4417076
[59,] 0.18208115 0.54158791 0.2763309
[60,] 0.06605319 0.29271592 0.6412309
[61,] 0.18292370 0.33488411 0.4821922
[62,] 0.35449474 0.08682098 0.5586843
[63,] 0.13539434 0.35287885 0.5117268
[64,] 0.35699517 0.31191344 0.3310914
[65,] 0.28440635 0.28779718 0.4277965
[66,] 0.16983919 0.51101230 0.3191485
[67,] 0.28582309 0.16311738 0.5510595
[68,] 0.35316709 0.20914643 0.4376865
[69,] 0.18100694 0.35365026 0.4653428
[70,] 0.15003428 0.17484900 0.6751167
[71,] 0.17752877 0.13926950 0.6832017
[72,] 0.22539027 0.24638748 0.5282222
[73,] 0.49304300 0.16871032 0.3382467
[74,] 0.23255657 0.22139577 0.5460477
[75,] 0.22035030 0.34052962 0.4391201
[76,] 0.17699354 0.17766021 0.6453463
[77,] 0.23604706 0.38301602 0.3809369
[78,] 0.21343176 0.23439251 0.5521757
[79,] 0.31161928 0.08573942 0.6026413
[80,] 0.41622634 0.21524186 0.3685318
[81,] 0.19359846 0.21342492 0.5929766
[82,] 0.24115032 0.19473928 0.5641104
[83,] 0.14985072 0.41543186 0.4347174
[84,] 0.20582387 0.46132395 0.3328522
[85,] 0.19151952 0.21742383 0.5910567
[86,] 0.23016880 0.20197343 0.5678578
[87,] 0.11852500 0.17587381 0.7056012
[88,] 0.21284618 0.25637078 0.5307830
[89,] 0.11756747 0.39038157 0.4920510
[90,] 0.16492242 0.13921792 0.6958597
[91,] 0.20511682 0.32775159 0.4671316
[92,] 0.12333633 0.32684158 0.5498221
[93,] 0.26340607 0.04689733 0.6896966
[94,] 0.34402229 0.18886469 0.4671130
[95,] 0.29172818 0.13348662 0.5747852
[96,] 0.29539679 0.25075352 0.4538497
[97,] 0.28938509 0.14724859 0.5633663
[98,] 0.14071609 0.27769015 0.5815938
[99,] 0.11608768 0.63164364 0.2522687
[100,] 0.10134970 0.29181076 0.6068395
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.