Last data update: 2014.03.03

R: Generating function for EuclRandMatrix-class
EuclRandMatrixR Documentation

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 "OptionalrSpace": domain of Map

dimension

positive integer: dimension of the range of Map

Range

object of class "OptionalrSpace": range of Map

Value

Object of class "EuclRandMatrix"

Author(s)

Matthias Kohl Matthias.Kohl@stamats.de

See Also

EuclRandMatrix-class

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))))
}

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(RandVar)
Loading required package: distr
Loading required package: startupmsg
:startupmsg>  Utilities for Start-Up Messages (version 0.9.3)
:startupmsg> 
:startupmsg>  For more information see ?"startupmsg",
:startupmsg>  NEWS("startupmsg")

Loading required package: sfsmisc
Loading required package: SweaveListingUtils
:SweaveListingUtils>  Utilities for Sweave Together with
:SweaveListingUtils>  TeX 'listings' Package (version
:SweaveListingUtils>  0.7.5)
:SweaveListingUtils> 
:SweaveListingUtils>  NOTE: Support for this package
:SweaveListingUtils>  will stop soon.
:SweaveListingUtils> 
:SweaveListingUtils>  Package 'knitr' is providing the
:SweaveListingUtils>  same functionality in a better
:SweaveListingUtils>  way.
:SweaveListingUtils> 
:SweaveListingUtils>  Some functions from package 'base'
:SweaveListingUtils>  are intentionally masked ---see
:SweaveListingUtils>  SweaveListingMASK().
:SweaveListingUtils> 
:SweaveListingUtils>  Note that global options are
:SweaveListingUtils>  controlled by
:SweaveListingUtils>  SweaveListingoptions() ---c.f.
:SweaveListingUtils>  ?"SweaveListingoptions".
:SweaveListingUtils> 
:SweaveListingUtils>  For more information see
:SweaveListingUtils>  ?"SweaveListingUtils",
:SweaveListingUtils>  NEWS("SweaveListingUtils")
:SweaveListingUtils>  There is a vignette to this
:SweaveListingUtils>  package; try
:SweaveListingUtils>  vignette("ExampleSweaveListingUtils").


Attaching package: 'SweaveListingUtils'

The following objects are masked from 'package:base':

    library, require

:distr>  Object Oriented Implementation of Distributions (version
:distr>  2.6)
:distr> 
:distr>  Attention: Arithmetics on distribution objects are
:distr>  understood as operations on corresponding random variables
:distr>  (r.v.s); see distrARITH().
:distr> 
:distr>  Some functions from package 'stats' are intentionally masked
:distr>  ---see distrMASK().
:distr> 
:distr>  Note that global options are controlled by distroptions()
:distr>  ---c.f. ?"distroptions".
:distr> 
:distr>  For more information see ?"distr", NEWS("distr"), as well as
:distr>    http://distr.r-forge.r-project.org/
:distr>  Package "distrDoc" provides a vignette to this package as
:distr>  well as to several extension packages; try
:distr>  vignette("distr").


Attaching package: 'distr'

The following objects are masked from 'package:stats':

    df, qqplot, sd

Loading required package: distrEx
:distrEx>  Extensions of Package 'distr' (version 2.6)
:distrEx> 
:distrEx>  Note: Packages "e1071", "moments", "fBasics" should be
:distrEx>  attached /before/ package "distrEx". See
:distrEx>  distrExMASK().Note: Extreme value distribution
:distrEx>  functionality has been moved to
:distrEx> 
:distrEx>        package "RobExtremes". See distrExMOVED().
:distrEx> 
:distrEx>  For more information see ?"distrEx", NEWS("distrEx"), as
:distrEx>  well as
:distrEx>    http://distr.r-forge.r-project.org/
:distrEx>  Package "distrDoc" provides a vignette to this package
:distrEx>  as well as to several related packages; try
:distrEx>  vignette("distr").


Attaching package: 'distrEx'

The following objects are masked from 'package:stats':

    IQR, mad, median, var

:RandVar>  Implementation of Random Variables (version 1.0)
:RandVar> 
:RandVar>  For more information see ?"RandVar", NEWS("RandVar"), as
:RandVar>  well as
:RandVar>    http://robast.r-forge.r-project.org/
:RandVar>  This package also includes a vignette; try
:RandVar>  vignette("RandVar").

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RandVar/EuclRandMatrix.Rd_%03d_medium.png", width=480, height=480)
> ### Name: EuclRandMatrix
> ### Title: Generating function for EuclRandMatrix-class
> ### Aliases: EuclRandMatrix
> ### Keywords: classes
> 
> ### ** 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]
An object of class "EuclRandVariable" 
length of Map:	 2 
Domain:	Real Space with dimension 1 
Range:	Euclidean Space with dimension 1 
> R1[1:2, 1:2]
An object of class "EuclRandMatrix" 
Dim of Map:	 2 2 
Domain:	Real Space with dimension 1 
Range:	Euclidean Space with dimension 1 
> Map(R1[1,2])
[[1]]
function (x) 
{
    x^4
}

> Map(t(R1)[2,1])
[[1]]
function (x) 
{
    f <- function (x) 
    {
        x^4
    }
    t(f(x))
}
<environment: 0x5260778>

> 
> R2 <- EuclRandMatrix(Map = L2, ncol = 2, Domain = Reals(), dimension = 1)
> (DL <- imageDistr(R2, Norm()))
An object of class "DistrList"
 [[1]] Distribution Object of Class: AbscontDistribution
 [[2]] Distribution Object of Class: AbscontDistribution
 [[3]] Distribution Object of Class: AbscontDistribution
 [[4]] Distribution Object of Class: AbscontDistribution
Warning messages:
1: In function (object)  :
  arithmetics on distributions are understood as operations on r.v.'s
see 'distrARITH()'; for switching off this warning see '?distroptions'
2: In function (object)  :
  slots d,p,q have been filled using simulations; for switching off this warning see '?distroptions'
> plot(DL)
> 
> Map(gamma(R2)) # "Math" group
[[1]]
function (x) 
{
    f1 <- function (x) 
    {
        exp(x)
    }
    gamma(f1(x))
}
<environment: 0x5fd4b68>

[[2]]
function (x) 
{
    f1 <- function (x) 
    {
        abs(x)
    }
    gamma(f1(x))
}
<environment: 0x5fd4b68>

[[3]]
function (x) 
{
    f1 <- function (x) 
    {
        sin(x)
    }
    gamma(f1(x))
}
<environment: 0x5fd4b68>

[[4]]
function (x) 
{
    f1 <- function (x) 
    {
        floor(x)
    }
    gamma(f1(x))
}
<environment: 0x5fd4b68>

> 
> ## "Arith" group
> Map(2/R1)
[[1]]
function (x) 
{
    f2 <- function (x) 
    {
        x
    }
    2/f2(x)
}
<environment: 0x5f6b8b8>

[[2]]
function (x) 
{
    f2 <- function (x) 
    {
        x^2
    }
    2/f2(x)
}
<environment: 0x5f6b8b8>

[[3]]
function (x) 
{
    f2 <- function (x) 
    {
        x^3
    }
    2/f2(x)
}
<environment: 0x5f6b8b8>

[[4]]
function (x) 
{
    f2 <- function (x) 
    {
        x^4
    }
    2/f2(x)
}
<environment: 0x5f6b8b8>

[[5]]
function (x) 
{
    f2 <- function (x) 
    {
        x^5
    }
    2/f2(x)
}
<environment: 0x5f6b8b8>

[[6]]
function (x) 
{
    f2 <- function (x) 
    {
        x^6
    }
    2/f2(x)
}
<environment: 0x5f6b8b8>

> Map(R2 * R2)
[[1]]
function (x) 
{
    f1 <- function (x) 
    {
        exp(x)
    }
    f2 <- function (x) 
    {
        exp(x)
    }
    f1(x) * f2(x)
}
<environment: 0x5ef17f0>

[[2]]
function (x) 
{
    f1 <- function (x) 
    {
        abs(x)
    }
    f2 <- function (x) 
    {
        abs(x)
    }
    f1(x) * f2(x)
}
<environment: 0x5ef17f0>

[[3]]
function (x) 
{
    f1 <- function (x) 
    {
        sin(x)
    }
    f2 <- function (x) 
    {
        sin(x)
    }
    f1(x) * f2(x)
}
<environment: 0x5ef17f0>

[[4]]
function (x) 
{
    f1 <- function (x) 
    {
        floor(x)
    }
    f2 <- function (x) 
    {
        floor(x)
    }
    f1(x) * f2(x)
}
<environment: 0x5ef17f0>

> 
> 
> ## 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))))
+ }
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))))
}
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>