wtpolyap: Polya Sampling from an Urn with Possibly Unequal Weights

Description Usage Arguments Value Examples

View source: R/wtpolyap.R

Description

Consider an urn containing a finite set of values along with their respective positive weights. An item is selected at random from the urn with probability proportional to its weight. Then it is returned to the urn and its weight is increased by one. The process is repeated on the adjusted urn. We continue until the total weight in the urn has been increased by k. The original composition of the urn along with the k selected values, in order, are returned.

Usage

1
wtpolyap(ysamp, wts, k)

Arguments

ysamp

A vector of real numbers which make up the urn.

wts

A vector of positive weights which defines the initial probability of selection.

k

A positive integer which specifies the number of Polya samples taken from the urn where after each draw the weight of the selected item is increased by one.

Value

The returned value is a vector of length equal to the length of the sample plus k.

Examples

1
wtpolyap(c(0,1,2),c(0.5,1,1.5),22)

Example output

Loading required package: rcdd
If you want correct answers, use rational arithmetic.
See the Warnings sections added to help pages for
    functions that do computational geometry.

 [1] 0 1 2 0 1 2 2 2 1 2 2 2 2 2 2 1 1 2 0 2 2 2 2 2 2

polyapost documentation built on Oct. 7, 2021, 5:10 p.m.