dTable.Rd
Retrieve or set the data table describing the discrete probability distribution
dTable(x, ...) # S3 method for Distribution dTable(x) # S3 method for Distribution dTable(x) <- value # S3 method for Distribution getData(x, ...) # S3 method for Distribution setData(x, value)
x | distribution |
---|---|
value | data.table, matrix, data.frame |
data.table
A discrete distribution describes the probability of occurrence of each value of a discrete random variable. A discrete random variable is a random variable that has countable values, such as a list of non-negative integers. With a discrete probability distribution, each possible value of the discrete random variable can be associated with a non-zero probability. Thus, a discrete probability distribution is often presented in tabular/matrix form.
In our case, we represent the discrete probability distribution as a matrix (data.table
) such that columns represent random variables and rows represent a unique combination of values of respective random variables. The last column is special - it contains a probability or a frequency of respective combination of random variables in the row. This column is denoted as MUDIM.frequency
. Columns are named by respective random variables.
When creating a new distribution, the data table does not have to contain a column named MUDIM.frequency
. It is created automatically.
Using functions dTable
and dTable<-
you can read and set the distribution data matrix.
Distribution
: Retrieve probability table
Distribution
: Set probability table
Distribution
: Retrieve probability table
Distribution
: Set probability table
#> A B MUDIM.frequency #> 1: 0 0 0.1 #> 2: 0 1 0.2 #> 3: 1 0 0.3 #> 4: 1 1 0.4v <- matrix(c(1:10, 1, 1:10, 1),ncol = 2, byrow = FALSE); #columns of variables colnames(v) <- c("A","B") print(v);#> A B #> [1,] 1 1 #> [2,] 2 2 #> [3,] 3 3 #> [4,] 4 4 #> [5,] 5 5 #> [6,] 6 6 #> [7,] 7 7 #> [8,] 8 8 #> [9,] 9 9 #> [10,] 10 10 #> [11,] 1 1# [,1] [,2] # [1,] 1 1 # [2,] 2 2 # [3,] 3 3 # [4,] 4 4 # [5,] 5 5 # [6,] 6 6 # [7,] 7 7 # [8,] 8 8 # [9,] 9 9 # [10,] 10 10 # [10,] 1 1 d <- Distribution("test") dTable(d) <- v dTable(d);#> A B MUDIM.frequency #> 1: 1 1 2 #> 2: 2 2 1 #> 3: 3 3 1 #> 4: 4 4 1 #> 5: 5 5 1 #> 6: 6 6 1 #> 7: 7 7 1 #> 8: 8 8 1 #> 9: 9 9 1 #> 10: 10 10 1