rFractionalWishart: Random Fractional Wishart Matrix

Description Usage Arguments Details Value References Examples

View source: R/rFractionalWishart.R

Description

Generate n random matrices, distributed according to the Wishart distribution with parameters Sigma and df, W_p(Sigma, df).

Usage

1
2
rFractionalWishart(n, df, Sigma, covariance = FALSE,
  simplify = "array")

Arguments

n

integer: the number of replications.

df

numeric parameter, “degrees of freedom”.

Sigma

positive definite (p * p) “scale” matrix, the matrix parameter of the distribution.

covariance

logical on whether a covariance matrix should be generated

simplify

logical or character string; should the result be simplified to a vector, matrix or higher dimensional array if possible? For sapply it must be named and not abbreviated. The default value, TRUE, returns a vector or matrix if appropriate, whereas if simplify = "array" the result may be an array of “rank” (=length(dim(.))) one higher than the result of FUN(X[[i]]).

Details

If X_1, ..., X_m is a sample of m independent multivariate Gaussians with mean vector 0, and covariance matrix Sigma, the distribution of M = X'X is W_p(Sigma, m).

Value

A numeric array of dimension p * p * n, where each array is a positive semidefinite matrix, a realization of the Wishart distribution W_p(Sigma, df)

References

Adhikari, S. (2008). Wishart random matrices in probabilistic structural mechanics. Journal of engineering mechanics, 134(12), doi: 10.1061/(ASCE)0733-9399(2008)134:12(1029).

Examples

1
rFractionalWishart(2, 22.5, diag(1, 20))

Example output

Attaching package:rWishartThe following object is masked frompackage:stats:

    rWishart

, , 1

             [,1]         [,2]        [,3]       [,4]       [,5]       [,6]
 [1,] 227.3400424 -28.92777257 -15.7091314 -19.111657 -1.9955855  11.711521
 [2,] -28.9277726 155.46358797  -4.0421071   2.469213  1.7259372   8.675951
 [3,] -15.7091314  -4.04210709  79.3414855  -0.574172  2.0931759  -3.348261
 [4,] -19.1116566   2.46921324  -0.5741720 140.805629 -4.4858976   1.028657
 [5,]  -1.9955855   1.72593721   2.0931759  -4.485898 34.2079060  13.145621
 [6,]  11.7115212   8.67595088  -3.3482609   1.028657 13.1456213 116.410392
 [7,]  -3.5855488  10.63878242   1.8020482  -8.343388  3.0907914  -4.627708
 [8,]  -5.2344835   9.86463813   1.9340584 -12.647050 -5.8572626  -9.867235
 [9,]   7.2372063  -5.60585506   6.3486273  -2.641505 -4.9028045  -7.919296
[10,]  -0.5218905  -0.59814195  14.4985201  -2.514111  5.6400200  -6.812899
[11,]   5.2447578   2.65628069   6.2800058 -15.612341 -4.6773754  -1.244814
[12,] -10.6679992  -0.35755522   9.6690284  -6.936134  1.8683728  -3.269700
[13,]  12.7987964 -13.08614315   1.3606202   9.678380  0.5190985   2.807234
[14,]   0.5105867  -2.62735811  -0.1968232   2.332331 -5.4638033   3.458920
[15,]   1.0598604  -8.74550233  -7.6071450  -1.306100 -1.2454749   3.752046
[16,]  -7.6779368   1.88138198   4.3178483   2.106791  3.2956554  -6.039764
[17,]   0.5569478  -5.36365162   5.1772603  -8.278664  5.1054856  -1.716953
[18,]   1.9432297  -4.75788791  -4.4889020   2.443566 -5.5541954  -2.446559
[19,]  -3.3128269  -0.46228373   3.6928392  -1.895497  1.7222935   1.473387
[20,]   0.4281565   0.01054848   0.0507884  -0.178266  0.1904332   1.127288
              [,7]         [,8]        [,9]      [,10]       [,11]
 [1,]  -3.58554876  -5.23448354  7.23720633 -0.5218905   5.2447578
 [2,]  10.63878242   9.86463813 -5.60585506 -0.5981419   2.6562807
 [3,]   1.80204817   1.93405836  6.34862733 14.4985201   6.2800058
 [4,]  -8.34338803 -12.64704985 -2.64150530 -2.5141109 -15.6123407
 [5,]   3.09079136  -5.85726261 -4.90280446  5.6400200  -4.6773754
 [6,]  -4.62770774  -9.86723515 -7.91929646 -6.8128993  -1.2448139
 [7,]  36.05756147   8.83821306 -0.02036627 -1.4088130  -4.7315187
 [8,]   8.83821306  58.43231693  1.51155169  1.1402774   5.7875724
 [9,]  -0.02036627   1.51155169 38.96783632  5.7648532  -1.0135871
[10,]  -1.40881300   1.14027740  5.76485319 50.1187563  -5.0144964
[11,]  -4.73151868   5.78757243 -1.01358709 -5.0144964  22.3344204
[12,]   2.18936797   4.23787668 -2.72174624  3.9923289   1.4163277
[13,] -14.09025265  -4.26967951  4.74462255 -8.4911253   6.9402579
[14,]  -1.75217473   7.20219264  1.07774411  0.0119133  -0.4262292
[15,]  -2.66751866   1.99477957  2.31450344 -5.0106841   0.6887500
[16,]   0.75781016   1.74366049  6.85410571  5.1122609 -10.1456736
[17,]   1.03825209   0.32623622  3.98541439  1.0256799   1.3034741
[18,]  -6.23978669   0.07492463  1.39258946 -2.2965242  -0.1894124
[19,]  -1.63941701   2.00448104 -5.95744293  0.5018147   1.7391015
[20,]   1.48034616  -0.38131004  0.45992364  0.1151233  -0.5743463
              [,12]       [,13]      [,14]      [,15]       [,16]       [,17]
 [1,] -10.667999187  12.7987964  0.5105867  1.0598604  -7.6779368  0.55694779
 [2,]  -0.357555216 -13.0861431 -2.6273581 -8.7455023   1.8813820 -5.36365162
 [3,]   9.669028403   1.3606202 -0.1968232 -7.6071450   4.3178483  5.17726034
 [4,]  -6.936134295   9.6783800  2.3323313 -1.3061005   2.1067905 -8.27866408
 [5,]   1.868372814   0.5190985 -5.4638033 -1.2454749   3.2956554  5.10548565
 [6,]  -3.269699851   2.8072342  3.4589196  3.7520458  -6.0397643 -1.71695282
 [7,]   2.189367967 -14.0902526 -1.7521747 -2.6675187   0.7578102  1.03825209
 [8,]   4.237876678  -4.2696795  7.2021926  1.9947796   1.7436605  0.32623622
 [9,]  -2.721746238   4.7446225  1.0777441  2.3145034   6.8541057  3.98541439
[10,]   3.992328912  -8.4911253  0.0119133 -5.0106841   5.1122609  1.02567991
[11,]   1.416327651   6.9402579 -0.4262292  0.6887500 -10.1456736  1.30347408
[12,]  29.882311308 -21.0545280 -5.3831947 -1.5982501  -2.6568437  4.59734742
[13,] -21.054528036  69.3973761 -1.1474795 -2.6948186  -4.2633299  2.44090079
[14,]  -5.383194658  -1.1474795 13.5863072  0.8318550   3.4120958 -2.74680221
[15,]  -1.598250090  -2.6948186  0.8318550 24.9544400  -2.8435208  0.94310704
[16,]  -2.656843691  -4.2633299  3.4120958 -2.8435208  29.8003178 -1.72857328
[17,]   4.597347419   2.4409008 -2.7468022  0.9431070  -1.7285733 13.56240553
[18,]  -4.304778978   0.9476917  1.6819331  6.8488828   3.6743205  1.94733871
[19,]   2.223337572  -1.3669113  2.0287242  1.0734772  -3.5060361 -4.47476018
[20,]  -0.001546977  -0.6208495  0.4493683 -0.1393863   0.1518481 -0.01395815
            [,18]      [,19]        [,20]
 [1,]  1.94322965 -3.3128269  0.428156507
 [2,] -4.75788791 -0.4622837  0.010548482
 [3,] -4.48890199  3.6928392  0.050788396
 [4,]  2.44356574 -1.8954965 -0.178266005
 [5,] -5.55419543  1.7222935  0.190433240
 [6,] -2.44655899  1.4733865  1.127287970
 [7,] -6.23978669 -1.6394170  1.480346162
 [8,]  0.07492463  2.0044810 -0.381310039
 [9,]  1.39258946 -5.9574429  0.459923637
[10,] -2.29652420  0.5018147  0.115123321
[11,] -0.18941238  1.7391015 -0.574346254
[12,] -4.30477898  2.2233376 -0.001546977
[13,]  0.94769167 -1.3669113 -0.620849529
[14,]  1.68193306  2.0287242  0.449368311
[15,]  6.84888278  1.0734772 -0.139386290
[16,]  3.67432049 -3.5060361  0.151848065
[17,]  1.94733871 -4.4747602 -0.013958149
[18,] 12.39260758 -5.1053840 -0.969000137
[19,] -5.10538401 11.6855792 -0.310388451
[20,] -0.96900014 -0.3103885  0.396357872

, , 2

             [,1]        [,2]        [,3]          [,4]        [,5]       [,6]
 [1,]  88.8809045   6.9751942  -0.2894928 -12.886513572  13.9374522 -5.1915504
 [2,]   6.9751942 134.9840155  -0.9852806   6.437573280  14.4837998  5.8966084
 [3,]  -0.2894928  -0.9852806  88.8353541  -1.747101856 -10.3461909 -2.7045736
 [4,] -12.8865136   6.4375733  -1.7471019 123.456440481   7.9273883  0.8216096
 [5,]  13.9374522  14.4837998 -10.3461909   7.927388303 136.9507716  3.0198158
 [6,]  -5.1915504   5.8966084  -2.7045736   0.821609550   3.0198158 81.8866512
 [7,]   6.9133230 -20.3940325  -2.6045770  10.710100324   1.6225417  2.9674880
 [8,]   6.7070815  -5.6577463  -0.8260750   3.064446045   0.5412052 -7.7033987
 [9,]  -8.0404395   8.4104832   5.7524242   4.659974833   1.9649242 12.9848057
[10,]  -6.4093079   5.9174432  -3.1795513 -26.280247808 -12.9080088  7.0336563
[11,]   2.0299918  -8.1932757  -7.9295903   0.805616823 -14.7021276 15.1123705
[12,]   4.8345150   3.9643735   2.0421328  -7.049095949   4.2394473  7.0789302
[13,]   3.0963375   5.6211372  -3.1857838   4.464730272  -2.3851926 10.6857388
[14,]  -1.3466553  -4.7901904   1.2337572  -0.009624001  -7.1025964 -8.2196241
[15,]   0.5642081  -0.1695940   2.8357109   0.699841235   2.9406989 -1.8211008
[16,]   2.8090635   5.2218430   0.1963142  -3.058618287  -4.7706557  1.1017005
[17,]   0.3734430   4.3391791  -4.5894654  -0.666313432   5.4091743  7.8288676
[18,]  -0.5359178  -0.3910417  -0.5029510   0.560287558  -0.8231613  7.4397302
[19,]  -1.2879393   1.1781039   0.3916049  -1.058916978  -3.2904659 -0.7993257
[20,]  -1.6141693   0.1232961  -5.0378214  -2.253328814   0.7951449  7.3625927
             [,7]       [,8]         [,9]        [,10]        [,11]      [,12]
 [1,]   6.9133230  6.7070815  -8.04043951  -6.40930786   2.02999182  4.8345150
 [2,] -20.3940325 -5.6577463   8.41048324   5.91744322  -8.19327573  3.9643735
 [3,]  -2.6045770 -0.8260750   5.75242418  -3.17955133  -7.92959028  2.0421328
 [4,]  10.7101003  3.0644460   4.65997483 -26.28024781   0.80561682 -7.0490959
 [5,]   1.6225417  0.5412052   1.96492417 -12.90800884 -14.70212761  4.2394473
 [6,]   2.9674880 -7.7033987  12.98480570   7.03365627  15.11237051  7.0789302
 [7,]  68.0959478  1.1337744  -7.41891741 -13.99137700   5.46751313 -1.7216783
 [8,]   1.1337744 23.5197706  -4.41034622  -0.63549225   7.86550000 -1.5017933
 [9,]  -7.4189174 -4.4103462  78.80418797   5.61196300 -10.58304120  5.4941645
[10,] -13.9913770 -0.6354923   5.61196300 109.92466149  -0.08578358 -2.1395088
[11,]   5.4675131  7.8655000 -10.58304120  -0.08578358  38.85622943  4.0269314
[12,]  -1.7216783 -1.5017933   5.49416453  -2.13950876   4.02693143 27.2727720
[13,]   4.8788844 -5.3100586  -7.92258808  -7.44688636  11.54383894 16.2031685
[14,]   7.9241919 -0.8312627   0.90705437   1.81668403   2.92937372  4.9669638
[15,]  -2.7985388  1.6536311   0.18756162  -3.30163898  -3.52207773  1.5751812
[16,] -10.6869229 -0.4809266   0.30960002   5.17910698   2.63716466 -4.0714366
[17,]  -4.4134743  0.8008605  -3.93074079  -2.61622662  -0.44402282 -2.1093310
[18,]  -2.0016753 -1.2657116  -0.02083836   0.72325141   0.73985473  0.7330361
[19,]  -0.8085887 -3.5899695  -0.63614908   1.98088577  -0.42668299  1.5841069
[20,]  -3.7409792  1.6259225   4.23105301  -1.39835247   0.59041901 -0.9372444
           [,13]        [,14]      [,15]       [,16]      [,17]       [,18]
 [1,]  3.0963375 -1.346655346  0.5642081   2.8090635  0.3734430 -0.53591777
 [2,]  5.6211372 -4.790190364 -0.1695940   5.2218430  4.3391791 -0.39104167
 [3,] -3.1857838  1.233757151  2.8357109   0.1963142 -4.5894654 -0.50295104
 [4,]  4.4647303 -0.009624001  0.6998412  -3.0586183 -0.6663134  0.56028756
 [5,] -2.3851926 -7.102596437  2.9406989  -4.7706557  5.4091743 -0.82316128
 [6,] 10.6857388 -8.219624050 -1.8211008   1.1017005  7.8288676  7.43973018
 [7,]  4.8788844  7.924191853 -2.7985388 -10.6869229 -4.4134743 -2.00167530
 [8,] -5.3100586 -0.831262683  1.6536311  -0.4809266  0.8008605 -1.26571157
 [9,] -7.9225881  0.907054373  0.1875616   0.3096000 -3.9307408 -0.02083836
[10,] -7.4468864  1.816684027 -3.3016390   5.1791070 -2.6162266  0.72325141
[11,] 11.5438389  2.929373720 -3.5220777   2.6371647 -0.4440228  0.73985473
[12,] 16.2031685  4.966963824  1.5751812  -4.0714366 -2.1093310  0.73303609
[13,] 38.3856150  3.196670895 -0.5530011  -4.8802072  0.3174936 -0.51066668
[14,]  3.1966709 16.053774694 -4.1861642  -3.2847040 -8.0739337 -0.31791787
[15,] -0.5530011 -4.186164177  7.5496739  -1.6240941  1.7099876 -1.04294418
[16,] -4.8802072 -3.284704050 -1.6240941  19.8975881  6.8507783  2.08094891
[17,]  0.3174936 -8.073933693  1.7099876   6.8507783 16.4011289 -0.10133546
[18,] -0.5106667 -0.317917872 -1.0429442   2.0809489 -0.1013355  5.04585900
[19,]  0.9914365  2.007574781 -0.9901634   0.8025488 -2.1167750  2.31966980
[20,] -2.4760553 -3.523721873  0.7839629   5.6617202  9.7950246  1.52989672
           [,19]      [,20]
 [1,] -1.2879393 -1.6141693
 [2,]  1.1781039  0.1232961
 [3,]  0.3916049 -5.0378214
 [4,] -1.0589170 -2.2533288
 [5,] -3.2904659  0.7951449
 [6,] -0.7993257  7.3625927
 [7,] -0.8085887 -3.7409792
 [8,] -3.5899695  1.6259225
 [9,] -0.6361491  4.2310530
[10,]  1.9808858 -1.3983525
[11,] -0.4266830  0.5904190
[12,]  1.5841069 -0.9372444
[13,]  0.9914365 -2.4760553
[14,]  2.0075748 -3.5237219
[15,] -0.9901634  0.7839629
[16,]  0.8025488  5.6617202
[17,] -2.1167750  9.7950246
[18,]  2.3196698  1.5298967
[19,]  4.9065890 -1.8195281
[20,] -1.8195281  9.7533497

rWishart documentation built on Nov. 20, 2019, 1:07 a.m.