R語言- Multinom 分佈(中文幫助)

Multinom {stats}算法

[轉載請註明出處,胡桃木屋 mathapply.cn 」R語言中文幫助「工做室譯]app

The Multinomial Distributiondom

多維正態分佈函數

Description(描述)this

    Generate multinomially distributed random number vectors and compute multinomial probabilities.
    生成多維正態分佈隨機數向量和計算多維正態分佈機率。component

Usage(用法)
rmultinom(n, size, prob)
dmultinom(x, size = NULL, prob, log = FALSE)orm

 

Arguments(參數)對象


     vector of length K of integers in 0:size.
     長度爲k的整數向量,從0:size遞歸


     number of random vectors to draw.
      要抽取的隨機向量的個數。
size  
      integer, say N, specifying the total number of objects that are put into K boxes in the typical multinomial experiment. For dmultinom, it defaults to sum(x).
      整數,天然數N,指定多維正態試驗中被放入K個盒子對象的總數量,對於dmultnom,它默認爲sum(x).  
prob 
      numeric non-negative vector of length K, specifying the probability for the K classes; is internally normalized to sum 1. Infinite and missing values are not allowed.接口

     長度爲K的非負數值向量,指定K類的機率,內部規範化爲1. 無限和缺失值是不容許的。  
log 
     logical; if TRUE, log probabilities are computed. 
     邏輯型,若是爲真,計算的是對數機率。

Details(詳細說明)

    If x is a K-component vector, dmultinom(x, prob) is the probability

          P(X[1]=x[1], … , X[K]=x[k]) = C * prod(j=1 , …, K) p[j]^x[j]

where C is the ‘multinomial coefficient’ C = N! / (x[1]! * … * x[K]!) and N = sum(j=1, …, K) x[j].

     若是x是由K部分組成的向量,機率dmultnom(x,prob)爲

          P(X[1]=x[1], … , X[K]=x[k]) = C * prod(j=1 , …, K) p[j]^x[j]

這裏 C 是 ‘多維正態係數’ C = N! / (x[1]! * … * x[K]!) and N = sum(j=1, …, K) x[j].


     By definition, each component X[j] is binomially distributed as Bin(size, prob[j]) for j = 1, …, K.
     根據定義,每一個組成X[j]是二項分佈,Bin(size, prob[j]), 其中j=1,...,K。

    The rmultinom() algorithm draws binomials X[j] from Bin(n[j], P[j]) sequentially, where n[1] = N (N := size), P[1] = p[1] (p is prob scaled to sum 1), and for j ≥ 2, recursively, n[j] = N - sum(k=1, …, j-1) X[k] and P[j] = p[j] / (1 - sum(p[1:(j-1)])).

    函數rmultinom() 的算法依次從Bin(n[j], P[j]) 中抽取X[j], 這裏n[1] = N (N := size), P[1] = p[1] (p 是規範化爲1的機率), 對於 j ≥ 2, 遞歸地, n[j] = N - sum(k=1, …, j-1) X[k] 和 P[j] = p[j] / (1 - sum(p[1:(j-1)])).

Value(返回值)

     For rmultinom(), an integer K x n matrix where each column is a random vector generated according to the desired multinomial law, and hence summing to size. Whereas the transposed result would seem more natural at first, the returned matrix is more efficient because of columnwise storage.
    對於rmultinom() 函數,返回的是一個K x n 的矩陣,這裏每一列是根據所需的多維正態分佈規則產生的隨機向量。初看起來雖然說將結果轉置看起來天然些,但按列返回的矩陣更有效,由於它是按列存儲的。

Note(注)

    dmultinom is currently not vectorized at all and has no C interface (API); this may be amended in the future.
    目前dmultinom函數沒有矢量化,也沒有C的接口(API), 未來會對此進行修訂。

See Also(另見)

    Distributions for standard distributions, including dbinom which is a special case conceptually.
    標準分佈見Distributions,包括dbinom,從概念上來講它是一種特殊狀況。

Examples(示例)
rmultinom(10, size = 12, prob = c(0.1,0.2,0.8))

pr <- c(1,3,6,10) # normalization not necessary for generation
rmultinom(10, 20, prob = pr)

## all possible outcomes of Multinom(N = 3, K = 3) X <- t(as.matrix(expand.grid(0:3, 0:3))); X <- X[, colSums(X) <= 3] X <- rbind(X, 3:3 - colSums(X)); dimnames(X) <- list(letters[1:3], NULL) X round(apply(X, 2, function(x) dmultinom(x, prob = c(1,2,5))), 3)

相關文章
相關標籤/搜索