Last data update: 2014.03.03

R: Generate Random Observations from a Multinomial Distribution
rmultinR Documentation

Generate Random Observations from a Multinomial Distribution

Description

This function generates a random observation from a multinomial distribution.

Usage

rmultin(n, p)

Arguments

n

Total size (and NOT the number of variables involved in the multinomial distribution).

p

Vector of probabilities. The sum of all its elements must be one.

Value

A vector with the sample which has been generated.

Examples

for(i in 1:10)
	print(rmultin(10, c(1/3, 1/3, 1/3) ))

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(DCluster)
Loading required package: boot
Loading required package: spdep
Loading required package: sp
Loading required package: Matrix
Loading required package: MASS
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DCluster/rmultin.Rd_%03d_medium.png", width=480, height=480)
> ### Name: rmultin
> ### Title: Generate Random Observations from a Multinomial Distribution
> ### Aliases: rmultin
> ### Keywords: distribution
> 
> ### ** Examples
> 
> for(i in 1:10)
+ 	print(rmultin(10, c(1/3, 1/3, 1/3) ))
[1] 0 4 6
[1] 7 2 1
[1] 6 3 1
[1] 4 5 1
[1] 3 4 3
[1] 4 5 1
[1] 3 3 4
[1] 5 2 3
[1] 4 2 4
[1] 5 1 4
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>