Evalue: Expected Value Calculation

Description Usage Arguments Value Examples

Description

This function is designed to find the expected value for g(x) or g(x, y) given a function g.

Usage

1
Evalue(g, rv)

Arguments

g

the function that we are looking for expected value

rv

given random variables

Value

the expected value of the given function

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
betaPDF <- function(x) {
ifelse(0 < x & x < 1, 2*x, 0)}
x1 = data.frame(oneDsample(f = betaPDF, N=10000, lb = 0, ub = 1))
g1 = function(x){x^2}
Evalue(g1,x1)

jointPDF <- function(x){
x1 = x[1]
x2 = x[2]
ifelse(0<x1 & x1 <1 & 0<x2 & x2<1 & 0<x1+x2 & x1+x2<1, 24*x1*x2, 0)}
xy = data.frame(twoDsample(f = jointPDF, N=10000, lbx=0, ubx=1, lby=0, uby=1))
g2 = function(x,y){x^2+y}
Evalue(g2,xy)

pinhuang0317/4800.Final.Project-KC.P.Production- documentation built on May 28, 2019, 7:37 a.m.