| Version: | 1.2.5 |
| Date: | 2025-01-12 |
| Title: | Implementation of Random Variables |
| Description: | Implements random variables by means of S4 classes and methods. |
| Depends: | R(≥ 3.4), methods, distr(≥ 2.8.0), distrEx(≥ 2.8.0) |
| Imports: | startupmsg(≥ 1.0.0) |
| ByteCompile: | yes |
| LazyLoad: | yes |
| License: | LGPL-3 |
| Encoding: | UTF-8 |
| URL: | https://r-forge.r-project.org/projects/robast/ |
| LastChangedDate: | {$LastChangedDate: 2025-01-12 01:01:19 +0100 (So, 12. Jan 2025) $} |
| LastChangedRevision: | {$LastChangedRevision: 1320 $} |
| VCS/SVNRevision: | 1319 |
| NeedsCompilation: | no |
| Packaged: | 2025-01-12 14:34:03 UTC; kohlm |
| Author: | Matthias Kohl |
| Maintainer: | Matthias Kohl <Matthias.Kohl@stamats.de> |
| Repository: | CRAN |
| Date/Publication: | 2025-01-14 06:20:01 UTC |
Implementation of Random Variables
Description
Implementation of random variables by means of S4 classes and methods.
Details
| Package: | RandVar |
| Version: | 1.2.5 |
| Date: | 2025-01-12 |
| Depends: | R(>= 3.4), methods, distr(>= 2.8.0), distrEx(>= 2.8.0) |
| Imports: | startupmsg(>= 1.0.0) |
| ByteCompile: | yes |
| License: | LGPL-3 |
| URL: | https://r-forge.r-project.org/projects/robast/ |
| VCS/SVNRevision: | 1319 |
Package versions
Note: The first two numbers of package versions do not necessarily reflect package-individual development, but rather are chosen for the RobAStXXX family as a whole in order to ease updating "depends" information.
Author(s)
Peter Ruckdeschel peter.ruckdeschel@uni-oldenburg.de,
Matthias Kohl Matthias.Kohl@stamats.de
Maintainer: Matthias Kohl matthias.kohl@stamats.de
References
M. Kohl (2005). Numerical Contributions to the Asymptotic Theory of Robustness. Dissertation. University of Bayreuth. See also https://www.stamats.de/wp-content/uploads/2018/04/ThesisMKohl.pdf
See Also
distr-package, distrEx-package
Examples
library(RandVar)
#vignette("RandVar")
Help function for generation of image distributions
Description
Generates an imageDistribution f(distr).
Usage
.getImageDistr(f, distr)
Arguments
f |
a function with values in R |
distr |
an object of class |
Details
works even if f(distr) fails;
if anything else fails does simulations of f(x),
x according to distr; uses RtoDPQ then;
does not check whether f(distr) has point masses
Value
image distribution of distr under f
Author(s)
Peter Ruckdeschel peter.ruckdeschel@uni-oldenburg.de
Generating function for EuclRandMatrix-class
Description
Generates an object of class "EuclRandMatrix".
Usage
EuclRandMatrix(Map = list(function(x){1}), nrow = 1, ncol = 1,
Domain = NULL, dimension = 1, Range)
Arguments
Map |
list of functions forming the map. |
nrow |
number of rows. |
ncol |
number of columns. |
Domain |
object of class |
dimension |
positive integer: dimension of the
range of |
Range |
object of class |
Value
Object of class "EuclRandMatrix"
Author(s)
Matthias Kohl Matthias.Kohl@stamats.de
See Also
Examples
L1 <- list(function(x){x}, function(x){x^2}, function(x){x^3}, function(x){x^4},
function(x){x^5}, function(x){x^6})
L2 <- list(function(x){exp(x)}, function(x){abs(x)},
function(x){sin(x)}, function(x){floor(x)})
R1 <- EuclRandMatrix(Map = L1, nrow = 3, Domain = Reals(), dimension = 1)
R1[1:2, 2]
R1[1:2, 1:2]
Map(R1[1,2])
Map(t(R1)[2,1])
R2 <- EuclRandMatrix(Map = L2, ncol = 2, Domain = Reals(), dimension = 1)
(DL <- imageDistr(R2, Norm()))
plot(DL)
Map(gamma(R2)) # "Math" group
## "Arith" group
Map(2/R1)
Map(R2 * R2)
## The function is currently defined as
function(Map = list(function(x){1}), nrow = 1, ncol = 1,
Domain = NULL, dimension = 1) {
if (missing(nrow))
nrow <- ceiling(length(Map)/ncol)
else if (missing(ncol))
ncol <- ceiling(length(Map)/nrow)
if(missing(Range))
return(new("EuclRandMatrix", Map = Map, Domain = Domain,
Range = EuclideanSpace(dimension = dimension),
Dim = as.integer(c(nrow, ncol))))
else
return(new("EuclRandMatrix", Map = Map, Domain = Domain,
Range = Range, Dim = as.integer(c(nrow, ncol))))
}
Euclidean random matrix
Description
Class of Euclidean random matrices.
Objects from the Class
Objects can be created by calls of the form new("EuclRandMatrix", ...).
More frequently they are created via the generating function
EuclRandMatrix.
Slots
Dimvector of positive integers: Dimensions of the random matrix.
MapObject of class
"list": list of functions.DomainObject of class
"OptionalrSpace"domain of the random matrix.RangeObject of class
"OptionalrSpace"range of the random matrix.
Extends
Class "EuclRandVariable", directly.
Class "RandVariable", by class "EuclRandVariable".
Methods
- coerce
signature(from = "EuclRandMatrix", to = "EuclRandVarList"): create a"EuclRandVarList"object from a Euclidean random matrix.- [
signature(x = "EuclRandMatrix"): generates a new Euclidean random variable/matrix by extracting elements of the slotMapofx.- Dim
signature(object = "EuclRandMatrix"): accessor function for slotDim.- Dim<-
signature(object = "EuclRandMatrix", ): replacement function for slotDim.- ncol
signature(x = "EuclRandMatrix"): number of columns ofx.- nrow
signature(x = "EuclRandMatrix"): number of rows ofx.- dimension
signature(object = "EuclRandMatrix"): dimension of the Euclidean random variable.- evalRandVar
signature(RandVar = "EuclRandMatrix", x = "numeric"): evaluate the slotMapofRandVaratx.- evalRandVar
signature(RandVar = "EuclRandMatrix", x = "matrix"): evaluate the slotMapofRandVaratx.- evalRandVar
signature(RandVar = "EuclRandMatrix", x = "numeric", distr = "Distribution"): evaluate the slotMapofRandVaratxassuming a probability space with distributiondistr. In casexdoes not lie in the support ofdistrNAis returned.- evalRandVar
signature(RandVar = "EuclRandMatrix", x = "matrix", distr = "Distribution"): evaluate the slotMapofRandVarat rows ofxassuming a probability space with distributiondistr. For those rows ofxwhich do not lie in the support ofdistrNAis returned.- t
signature(x = "EuclRandMatrix"): transposesx. In addition, the results of the functions in the slotMapofxare transposed.- show
signature(object = "EuclRandMatrix")- %*%
signature(x = "matrix", y = "EuclRandMatrix"): matrix multiplication ofxandy. Generates an object of class"EuclRandMatrix".- %*%
signature(x = "numeric", y = "EuclRandMatrix"): matrix multiplication ofxandy. Generates an object of class"EuclRandMatrix".- %*%
signature(x = "EuclRandVariable", y = "EuclRandMatrix"): matrix multiplication ofxandy. Generates an object of class"EuclRandMatrix".- %*%
signature(x = "EuclRandMatrix", y = "matrix"): matrix multiplication ofxandy. Generates an object of class"EuclRandMatrix".- %*%
signature(x = "EuclRandMatrix", y = "numeric"): matrix multiplication ofxandy. Generates an object of class"EuclRandMatrix".- %*%
signature(x = "EuclRandMatrix", y = "EuclRandMatrix"): matrix multiplication ofxandy. Generates an object of class"EuclRandMatrix".- %*%
signature(x = "EuclRandMatrix", y = "EuclRandVariable"): matrix multiplication ofxandy. Generates an object of class"EuclRandMatrix".- Arith
signature(e1 = "numeric", e2 = "EuclRandMatrix"): Given a numeric vectore1, a Euclidean random matrixe2and an arithmetic operatorop, the Euclidean random matrixe1 op e2is returned.- Arith
signature(e1 = "EuclRandMatrix", e2 = "numeric"): Given a Euclidean random matrixe1, a numeric vectore2, and an arithmetic operatorop, the Euclidean random matrixe1 op e2is returned.- Arith
signature(e1 = "EuclRandMatrix", e2 = "EuclRandMatrix"): Given two Euclidean random matricese1ande2, and an arithmetic operatorop, the Euclidean random matrixe1 op e2is returned.- Math
signature(x = "EuclRandMatrix"): Given a"Math"group genericfct, the Euclidean random matrixfct(x)is returned.- E
signature(object = "UnivariateDistribution", fun = "EuclRandMatrix", cond = "missing"): expectation offununder univariate distributions.- E
signature(object = "AbscontDistribution", fun = "EuclRandMatrix", cond = "missing"): expectation offununder absolutely continuous univariate distributions.- E
signature(object = "DiscreteDistribution", fun = "EuclRandMatrix", cond = "missing"): expectation offununder discrete univariate distributions.- E
signature(object = "MultivariateDistribution", fun = "EuclRandMatrix", cond = "missing"): expectation offununder multivariate distributions.- E
signature(object = "DiscreteMVDistribution", fun = "EuclRandMatrix", cond = "missing"): expectation offununder discrete multivariate distributions.- E
signature(object = "UnivariateCondDistribution", fun = "EuclRandMatrix", cond = "numeric"): conditional expectation offununder conditional univariate distributions.- E
signature(object = "AbscontCondDistribution", fun = "EuclRandMatrix", cond = "numeric"): conditional expectation offununder absolutely continuous conditional univariate distributions.- E
signature(object = "DiscreteCondDistribution", fun = "EuclRandMatrix", cond = "numeric"): conditional expectation offununder discrete conditional univariate distributions.
Author(s)
Matthias Kohl Matthias.Kohl@stamats.de
See Also
EuclRandMatrix, RandVariable-class,
EuclRandVariable-class, EuclRandVarList-class,
Distribution-class, Arith,
Math, E
Examples
L1 <- list(function(x){x}, function(x){x^2}, function(x){x^3}, function(x){x^4},
function(x){x^5}, function(x){x^6})
L2 <- list(function(x){exp(x)}, function(x){abs(x)},
function(x){sin(x)}, function(x){floor(x)})
R1 <- new("EuclRandMatrix", Map = L1, Dim = as.integer(c(3,2)),
Domain = Reals(), Range = Reals())
dimension(R1)
R1[1:2, 2]
R1[1:2, 1:2]
Map(R1[1,2])
Map(t(R1)[2,1])
R2 <- EuclRandMatrix(Map = L2, ncol = 2, Domain = Reals(), dimension = 1)
dimension(R2)
(DL <- imageDistr(R2, Norm()))
plot(DL)
Map(gamma(R2)) # "Math" group
## "Arith" group
Map(2/R1)
Map(R2 * R2)
Generating function for EuclRandVarList-class
Description
Generates an object of class "EuclRandVarList".
Usage
EuclRandVarList(...)
Arguments
... |
Objects of class |
Value
Object of class "EuclRandVarList"
Author(s)
Matthias Kohl Matthias.Kohl@stamats.de
See Also
Examples
L1 <- list(function(x){x}, function(x){x^2}, function(x){x^3}, function(x){x^4},
function(x){x^5}, function(x){x^6})
L2 <- list(function(x){exp(x)}, function(x){abs(x)},
function(x){sin(x)}, function(x){floor(x)})
R1 <- new("EuclRandVariable", Map = L2, Domain = Reals(), Range = Reals())
R2 <- EuclRandMatrix(Map = L1, ncol = 2, Domain = Reals(), dimension = 1)
R3 <- EuclRandMatrix(Map = L2, ncol = 2, Domain = Reals(), dimension = 1)
(RL1 <- EuclRandVarList(R1, R2, R3))
is(R1, "EuclRandVarList")
as(R1, "EuclRandVarList")
is(R2, "EuclRandVarList")
as(R2, "EuclRandVarList")
Map(exp(RL1)[[1]]) # "Math" group
## "Arith" group
Map((1 + RL1)[[1]])
Map((RL1 * 2)[[2]])
Map((RL1 / RL1)[[3]])
## The function is currently defined as
function(...){
new("EuclRandVarList", list(...))
}
List of Euclidean random variables
Description
Create a list of Euclidean random variables
Objects from the Class
Objects can be created by calls of the form new("EuclRandVarList", ...).
More frequently they are created via the generating function
EuclRandVarList.
Slots
.DataObject of class
"list". A list of Euclidean random variables.
Extends
Class "list", from data part.
Class "vector", by class "list".
Methods
- coerce
signature(from = "EuclRandVariable", to = "EuclRandVarList"): create a"EuclRandVarList"object from a Euclidean random variable.- coerce
signature(from = "EuclRandMatrix", to = "EuclRandVarList"): create a"EuclRandVarList"object from a Euclidean random matrix.- numberOfMaps
signature(object = "EuclRandVarList"): number of functions contained in the slotsMapof the members ofobject.- dimension
signature(object = "EuclRandVarList"): dimension of the Euclidean random variable.- evalRandVar
signature(RandVar = "EuclRandVarList", x = "numeric"): evaluate the elements ofRandVaratx.- evalRandVar
signature(RandVar = "EuclRandVarList", x = "matrix"): evaluate the elements ofRandVarat rows ofx.- evalRandVar
signature(RandVar = "EuclRandVarList", x = "numeric", distr = "Distribution"): evaluate the elements ofRandVaratxassuming a probability space with distributiondistr. In casexdoes not lie in the support ofdistrNAis returned.- evalRandVar
signature(RandVar = "EuclRandVarList", x = "matrix", distr = "Distribution"): evaluate the elements ofRandVarat rows ofxassuming a probability space with distributiondistr. For those rows ofxwhich do not lie in the support ofdistrNAis returned.- imageDistr
signature(RandVar = "EuclRandVarList", distr = "Distribution"): image distribution ofdistrunderRandVar. Returns an object of class"DistrList".- show
signature(object = "EuclRandVarList")- t
signature(x = "EuclRandVarList"): returns an object of class"EuclRandVarList"where the rhe results of the functions in the slotsMapof the members ofxare transposed.- %m%
signature(x = "EuclRandVarList", y = "EuclRandVarList"): matrix multiplication for objects of class"EuclRandVarList". Generates an object of class"EuclRandVarList".- %*%
signature(x = "matrix", y = "EuclRandVarList"): matrix multiplication ofxandy. Generates an object of class"EuclRandMatrix".- %*%
signature(x = "EuclRandVarList", y = "matrix"): matrix multiplication ofxandy. Generates an object of class"EuclRandMatrix".- Arith
signature(e1 = "numeric", e2 = "EuclRandVarList"): Given a numeric vectore1, a list of Euclidean random variablese2and an arithmetic operatorop, the list of Euclidean random variablese1 op e2is returned.- Arith
signature(e1 = "EuclRandVarList", e2 = "numeric"): Given a numeric vectore2, a list of Euclidean random variablese1and an arithmetic operatorop, the list of Euclidean random variablese1 op e2is returned.- Arith
signature(e1 = "EuclRandVarList", e2 = "EuclRandVarList"): Given two lists of Euclidean random variablese1,e2and an arithmetic operatorop, the list of Euclidean random variablese1 op e2is returned.- Math
signature(x = "EuclRandVarList"): Given a"Math"group genericfct, the list of Euclidean random variablesfct(x)is returned.- E
signature(object = "UnivariateDistribution", fun = "EuclRandVarList", cond = "missing"): expectation offununder univariate distributions.- E
signature(object = "AbscontDistribution", fun = "EuclRandVarList", cond = "missing"): expectation offununder absolutely continuous univariate distributions.- E
signature(object = "DiscreteDistribution", fun = "EuclRandVarList", cond = "missing"): expectation offununder discrete univariate distributions.- E
signature(object = "MultivariateDistribution", fun = "EuclRandVarList", cond = "missing"): expectation offununder multivariate distributions.- E
signature(object = "DiscreteMVDistribution", fun = "EuclRandVarList", cond = "missing"): expectation offununder discrete multivariate distributions.- E
signature(object = "UnivariateCondDistribution", fun = "EuclRandVarList", cond = "numeric"): expectation offununder conditional univariate distributions.- E
signature(object = "AbscontCondDistribution", fun = "EuclRandVarList", cond = "numeric"): expectation offununder absolutely continuous conditional univariate distributions.- E
signature(object = "DiscreteCondDistribution", fun = "EuclRandVarList", cond = "numeric"): expectation offununder discrete conditional univariate distributions.
Author(s)
Matthias Kohl Matthias.Kohl@stamats.de
See Also
EuclRandMatrix, RandVariable-class,
EuclRandVariable-class, EuclRandMatrix-class,
Distribution-class, Arith,
Math, E
Examples
L1 <- list(function(x){x}, function(x){x^2}, function(x){x^3}, function(x){x^4},
function(x){x^5}, function(x){x^6})
L2 <- list(function(x){exp(x)}, function(x){abs(x)},
function(x){sin(x)}, function(x){floor(x)})
R1 <- new("EuclRandVariable", Map = L2, Domain = Reals(), Range = Reals())
R2 <- EuclRandMatrix(Map = L1, ncol = 2, Domain = Reals(), dimension = 1)
R3 <- EuclRandMatrix(Map = L2, ncol = 2, Domain = Reals(), dimension = 1)
(RL1 <- new("EuclRandVarList", list(R1, R2, R3)))
dimension(RL1)
as(R1, "EuclRandVarList")
as(R2, "EuclRandVarList")
Map(exp(RL1)[[1]]) # "Math" group
## "Arith" group
Map((1 + RL1)[[1]])
Map((RL1 * 2)[[2]])
Map((RL1 / RL1)[[3]])
Generating function for EuclRandVariable-class
Description
Generates an object of class "EuclRandVariable".
Usage
EuclRandVariable(Map = list(function(x){1}), Domain = NULL,
dimension = 1, Range)
Arguments
Map |
list of functions forming the map. |
Domain |
object of class |
dimension |
positive integer: dimension of the
range of |
Range |
object of class |
Value
Object of class "EuclRandVariable"
Author(s)
Matthias Kohl Matthias.Kohl@stamats.de
See Also
Examples
L1 <- list(function(x){x}, function(x){x^2}, function(x){x^3}, function(x){x^4})
L2 <- list(function(x){exp(x)}, function(x){abs(x)},
function(x){sin(x)}, function(x){floor(x)})
R1 <- EuclRandVariable(Map = L1, Domain = Reals(), dimension = 1)
Map(R1)
Range(R1)
Range(R1) <- Reals()
R1[2]
Map(R1[3])
Map(R1[c(1,2,4)])
Map(R1[2:4])
set.seed(123)
evalRandVar(R1, rnorm(1))
x <- as.matrix(rnorm(10))
res.R1 <- evalRandVar(R1, x)
res.R1[2,,] # results for Map(R1)[[2]](x)
res.R1[2,1,] # results for Map(R1)[[2]](x[1,])
R2 <- EuclRandVariable(L2, Domain = Reals(), dimension = 1)
DL1 <- imageDistr(R2, Norm())
plot(DL1)
Domain(R2) <- EuclideanSpace(dimension = 2)
Range(R2) <- EuclideanSpace(dimension = 2)
(X <- matrix(c(x, rnorm(10)), ncol = 2))
res.R2 <- evalRandVar(R2, X)
res.R2[3,,1] # results for Map(R2)[[3]](X[,1])
Map(log(abs(R2))) # "Math" group generic
# "Arith" group generic
Map(3 + R1)
Map(c(1,3,5) * R1)
try(1:5 * R1) # error
Map(1:2 * R2)
Map(R2 - 5)
Map(R1 ^ R1)
## The function is currently defined as
function(Map = list(function(x){1}), Domain = NULL, dimension = 1, Range) {
if(missing(Range))
return(new("EuclRandVariable", Map = Map, Domain = Domain,
Range = EuclideanSpace(dimension = dimension)))
else
return(new("EuclRandVariable", Map = Map, Domain = Domain,
Range = Range))
}
Euclidean random variable
Description
Class of Euclidean random variables.
Objects from the Class
Objects can be created by calls of the form new("EuclRandVariable", ...).
More frequently they are created via the generating function
EuclRandVariable.
Slots
MapObject of class
"list": list of functions.DomainObject of class
"OptionalrSpace": domain of the random variable.RangeObject of class
"EuclideanSpace": range of the random variable.
Extends
Class "RandVariable", directly.
Methods
- coerce
signature(from = "EuclRandVariable", to = "EuclRandMatrix"): create a"EuclRandMatrix"object from a Euclidean random variable.- coerce
signature(from = "EuclRandVariable", to = "EuclRandVarList"): create a"EuclRandVarList"object from a Euclidean random variable.- Range<-
signature(object = "EuclRandVariable"): replacement function for the slotRange.- [
signature(x = "EuclRandVariable"): generates a new Euclidean random variable by extracting elements of the slotMapofx.- evalRandVar
signature(RandVar = "EuclRandVariable", x = "numeric", distr = "missing"): evaluate the slotMapofRandVaratx.- evalRandVar
signature(RandVar = "EuclRandVariable", x = "matrix", distr = "missing"): evaluate the slotMapofRandVarat rows ofx.- evalRandVar
signature(RandVar = "EuclRandVariable", x = "numeric", distr = "Distribution"): evaluate the slotMapofRandVaratxassuming a probability space with distributiondistr. In casexdoes not lie in the support ofdistrNAis returned.- evalRandVar
signature(RandVar = "EuclRandVariable", x = "matrix", distr = "Distribution"): evaluate the slotMapofRandVarat rows ofxassuming a probability space with distributiondistr. For those rows ofxwhich do not lie in the support ofdistrNAis returned.- imageDistr
signature(RandVar = "EuclRandVariable", distr = "Distribution"): image distribution ofdistrunderRandVar. Returns an object of class"DistrList".- dimension
signature(object = "EuclRandVariable"): dimension of the Euclidean random variable.- t
signature(x = "EuclRandVariable"): returns an object of class"EuclRandMatrix"where the rhe results of the functions in the slotMapofxare transposed.- %*%
signature(x = "matrix", y = "EuclRandVariable"): matrix multiplication ofxandy. Generates an object of class"EuclRandMatrix".- %*%
signature(x = "EuclRandVariable", y = "matrix"): matrix multiplication ofxandy. Generates an object of class"EuclRandMatrix".- %*%
signature(x = "numeric", y = "EuclRandVariable"): generates an object of class"EuclRandMatrix"(1 x 1 matrix) by multiplying (scalar/innner product)xandy.- %*%
signature(x = "EuclRandVariable", y = "numeric"): generates an object of class"EuclRandMatrix"(1 x 1 matrix) by multiplying (scalar/innner product)xandy.- %*%
signature(x = "EuclRandVariable", y = "EuclRandVariable"): generates an object of class"EuclRandMatrix"(1 x 1 matrix) by multiplying (scalar/innner product)xandy.- %*%
signature(x = "EuclRandVariable", y = "EuclRandMatrix"): matrix multiplication ofxandy. Generates an object of class"EuclRandMatrix".- %*%
signature(x = "EuclRandMatrix", y = "EuclRandVariable"): matrix multiplication ofxandy. Generates an object of class"EuclRandMatrix".- Arith
signature(e1 = "numeric", e2 = "EuclRandVariable"): Given a numeric vectore1, a Euclidean random variablee2and an arithmetic operatorop, the Euclidean random variablee1 op e2is returned.- Arith
signature(e1 = "EuclRandVariable", e2 = "numeric"): Given a numeric vectore2, a Euclidean random variablee1and an arithmetic operatorop, the Euclidean random variablee1 op e2is returned.- Arith
signature(e1 = "EuclRandVariable", e2 = "EuclRandVariable"): Given two Euclidean random variablese1,e2and an arithmetic operatorop, the Euclidean random variablee1 op e2is returned.- Math
signature(x = "EuclRandVariable"): Given a"Math"group genericfct, the Euclidean random variablefct(x)is returned.- E
signature(object = "UnivariateDistribution", fun = "EuclRandVariable", cond = "missing"): expectation offununder univariate distributions.- E
signature(object = "AbscontDistribution", fun = "EuclRandVariable", cond = "missing"): expectation offununder absolutely continuous univariate distributions.- E
signature(object = "DiscreteDistribution", fun = "EuclRandVariable", cond = "missing"): expectation offununder discrete univariate distributions.- E
signature(object = "MultivariateDistribution", fun = "EuclRandVariable", cond = "missing"): expectation offununder multivariate distributions.- E
signature(object = "DiscreteMVDistribution", fun = "EuclRandVariable", cond = "missing"): expectation offununder discrete multivariate distributions.- E
signature(object = "UnivariateCondDistribution", fun = "EuclRandVariable", cond = "numeric"): conditional expectation offununder conditional univariate distributions.- E
signature(object = "UnivariateCondDistribution", fun = "EuclRandVariable", cond = "numeric"): conditional expectation offununder absolutely continuous conditional univariate distributions.- E
signature(object = "UnivariateCondDistribution", fun = "EuclRandVariable", cond = "numeric"): conditional expectation offununder discrete conditional univariate distributions.
Author(s)
Matthias Kohl Matthias.Kohl@stamats.de
See Also
EuclRandVariable, RandVariable-class,
EuclRandMatrix-class, EuclRandVarList-class,
Distribution-class, Arith,
Math, E
Examples
L1 <- list(function(x){x}, function(x){x^2}, function(x){x^3}, function(x){x^4})
L2 <- list(function(x){exp(x)}, function(x){abs(x)},
function(x){sin(x)}, function(x){floor(x)})
R1 <- new("EuclRandVariable", Map = L1, Domain = Reals(), Range = Reals())
dimension(R1)
Map(R1)
Range(R1)
R1[2]
Map(R1[3])
Map(R1[c(1,2,4)])
Map(R1[2:4])
set.seed(123)
evalRandVar(R1, rnorm(1))
x <- as.matrix(rnorm(10))
res.R1 <- evalRandVar(R1, x)
res.R1[2,,] # results for Map(R1)[[2]](x)
res.R1[2,1,] # results for Map(R1)[[2]](x[1,])
R2 <- EuclRandVariable(L2, Domain = Reals(), dimension = 1)
dimension(R2)
DL1 <- imageDistr(R2, Norm())
plot(DL1)
Domain(R2) <- EuclideanSpace(dimension = 2)
Range(R2) <- EuclideanSpace(dimension = 2)
dimension(R2)
(X <- matrix(c(x, rnorm(10)), ncol = 2))
res.R2 <- evalRandVar(R2, X)
res.R2[3,,1] # results for Map(R2)[[3]](X[,1])
Map(log(abs(R2))) # "Math" group generic
# "Arith" group generic
Map(3 + R1)
Map(c(1,3,5) * R1)
try(1:5 * R1) # error
Map(1:2 * R2)
Map(R2 - 5)
Map(R1 ^ R1)
Optional rSpace
Description
Optional object of class "rSpace".
Objects from the Class
A virtual Class: No objects may be created from it.
Author(s)
Matthias Kohl Matthias.Kohl@stamats.de
See Also
Generating function for RandVariable-class
Description
Generates an object of class "RandVariable".
Usage
RandVariable(Map = list(function(x){}), Domain = NULL, Range = NULL)
Arguments
Map |
list of functions forming the map. |
Domain |
domain of |
Range |
range of |
Value
Object of class "RandVariable"
Author(s)
Matthias Kohl Matthias.Kohl@stamats.de
See Also
Examples
(R1 <- RandVariable())
Map(R1)
Domain(R1)
Range(R1)
Map(R1) <- list(function(x){ceiling(x)}, function(x){floor(x)})
Domain(R1) <- Reals()
Range(R1) <- Naturals()
R1
Map(R1)
length(R1)
R2 <- R1
Domain(R2) <- Naturals()
compatibleDomains(R1, R2)
Domain(R2) <- NULL
compatibleDomains(R1, R2)
Domain(R2) <- EuclideanSpace(dimension = 1)
compatibleDomains(R1, R2)
Domain(R2) <- EuclideanSpace(dimension = 2)
compatibleDomains(R1, R2)
## The function is currently defined as
function(Map = list(function(x){ }), Domain = NULL, Range = NULL) {
return(new("RandVariable", Map = Map, Domain = Domain, Range = Range))
}
Random variable
Description
Class of random variables; i.e., measurable maps from
Domain to Range. The elements contained in
the list Map are functions in one(!) argument named “x”.
Objects from the Class
Objects can be created by calls of the form new("RandVariable", ...).
More frequently they are created via the generating function
RandVariable.
Slots
MapObject of class
"list": list of functions.DomainObject of class
"OptionalrSpace": domain of the random variable.RangeObject of class
"OptionalrSpace": range of the random variable.
Methods
- Map
signature(object = "RandVariable"): accessor function for the slotMap.- Domain
signature(object = "RandVariable"): accessor function for the slotDomain.- Range
signature(object = "RandVariable"): accessor function for the slotRange.- Map<-
signature(object = "RandVariable"): replacement function for the slotMap.- Domain<-
signature(object = "RandVariable"): replacement function for the slotDomain.- Range<-
signature(object = "RandVariable"): replacement function for the slotRange.- compatibleDomains
signature(e1 = "RandVariable", e2 = "RandVariable"): test if the domains of two random variables are compatible.- length
signature(object = "RandVariable"): length of the list of functions in slotMap.- show
signature(object = "RandVariable")
Author(s)
Matthias Kohl Matthias.Kohl@stamats.de
See Also
RandVariable, EuclRandVariable-class,
EuclRandMatrix-class, EuclRandVarList-class
Examples
(R1 <- new("RandVariable"))
Map(R1)
Domain(R1)
Range(R1)
Map(R1) <- list(function(x){ceiling(x)}, function(x){floor(x)})
Domain(R1) <- Reals()
Range(R1) <- Naturals()
R1
Map(R1)
length(R1)
R2 <- R1
Domain(R2) <- Naturals()
compatibleDomains(R1, R2)
Domain(R2) <- NULL
compatibleDomains(R1, R2)
Domain(R2) <- EuclideanSpace(dimension = 1)
compatibleDomains(R1, R2)
Domain(R2) <- EuclideanSpace(dimension = 2)
compatibleDomains(R1, R2)
Generating function for RealRandVariable-class
Description
Generates an object of class "RealRandVariable".
Usage
RealRandVariable(Map = list(function(x) {1}), Domain = NULL, Range)
Arguments
Map |
list of functions forming the map. |
Domain |
domain of |
Range |
range of |
Value
Object of class "RealRandVariable"
Author(s)
Matthias Kohl Matthias.Kohl@stamats.de
See Also
Examples
RealRandVariable(Map = list(function(x){x}), Domain = Reals())
## The function is currently defined as
function(Map = list(function(x){1}), Domain = NULL, Range) {
if(missing(Range)) Range <- Reals()
if(!is(Range, "Reals"))
stop("'Range' has to be of class 'Reals'")
return(new("RealRandVariable", Map = Map,
Domain = Domain, Range = Reals()))
}
Real random variable
Description
Class of real random variables.
Objects from the Class
Objects can be created by calls of the form new("RealRandVariable", ...).
More frequently they are created via the generating function
EuclRandVariable.
Slots
MapObject of class
"list": list of functions.DomainObject of class
"OptionalrSpace": domain of the random variable.RangeObject of class
"Reals": range of the random variable.
Extends
Class "EuclRandVariable", directly.
Class "RandVariable", by class "EuclRandVariable".
Methods
- Range<-
signature(object = "EuclRandVariable"): replacement function for the slotRange.
Author(s)
Matthias Kohl Matthias.Kohl@stamats.de
See Also
Examples
new("RealRandVariable", Map=list(function(x){x}), Range = Reals())