Mathematical and statistical functions for the Categorical distribution, which is commonly used in classification supervised learning.
Returns an R6 object inheriting from class SDistribution.
Categorical$new(..., probs, decorators = NULL, verbose = FALSE)
Argument | Type | Details |
... |
ANY | elements in the support Set. See details. |
probs |
numeric | vector of probabilities. See details. |
decorators
Decorator
decorators to add functionality. See details.
The Categorical distribution is parameterised with a series of elements for the support set and probs
determining the probability of each category occurring. The length of the probability list should equal the number of elements. The probability vector is automatically normalised with
Variable | Return |
name |
Name of distribution. |
short_name |
Id of distribution. |
description |
Brief description of distribution. |
Accessor Methods | Link |
decorators() |
decorators |
traits() |
traits |
valueSupport() |
valueSupport |
variateForm() |
variateForm |
type() |
type |
properties() |
properties |
support() |
support |
symmetry() |
symmetry |
sup() |
sup |
inf() |
inf |
dmax() |
dmax |
dmin() |
dmin |
skewnessType() |
skewnessType |
kurtosisType() |
kurtosisType |
Statistical Methods
Link
pdf(x1, ..., log = FALSE, simplify = TRUE)
pdf
cdf(x1, ..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE)
cdf
quantile(p, ..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE)
quantile.Distribution
rand(n, simplify = TRUE)
rand
mean()
mean.Distribution
variance()
variance
stdev()
stdev
prec()
prec
cor()
cor
skewness()
skewness
kurtosis(excess = TRUE)
kurtosis
entropy(base = 2)
entropy
mgf(t)
mgf
cf(t)
cf
pgf(z)
pgf
median()
median.Distribution
iqr()
iqr
mode(which = "all")
mode
Parameter Methods
Link
parameters(id)
parameters
getParameterValue(id, error = "warn")
getParameterValue
setParameterValue(..., lst = NULL, error = "warn")
setParameterValue
Validation Methods
Link
liesInSupport(x, all = TRUE, bound = FALSE)
liesInSupport
liesInType(x, all = TRUE, bound = FALSE)
liesInType
Representation Methods
Link
strprint(n = 2)
strprint
print(n = 2)
print
summary(full = T)
summary.Distribution
The Categorical distribution parameterised with a given support set,
The distribution is supported on
Only the mode, pdf, cdf, quantile and rand are available for this Distribution, all other methods return NaN
. Sampling from this distribution is performed with the sample
function with the elements given as the support set and the probabilities from the probs
parameter. The cdf and quantile assumes that the elements are supplied in an indexed order (otherwise the results are meaningless).
McLaughlin, M. P. (2001). A compendium of common probability distributions (pp. 2014-01). Michael P. McLaughlin.
listDistributions
for all available distributions. sample
for the sampling function.
# NOT RUN {
# Note probabilities are automatically normalised
x = Categorical$new("Bapple","Banana",2,probs=c(0.2,0.4,1))
# Only the probabilities can be changed and must the same length as in construction
x$setParameterValue(probs = c(0.1,0.2,0.7))
# d/p/q/r
x$pdf(c("Bapple", "Carrot", 1, 2))
x$cdf("Banana") # Assumes ordered in construction
x$quantile(0.42) # Assumes ordered in construction
x$rand(10)
# Statistics
x$mode()
summary(x)
# }
Run the code above in your browser using DataLab