probability: Conditional probability calculation

Description Usage Arguments Value Examples

View source: R/conditional probability.R

Description

The goal of the function is used to compute the probability of the given ramdon variables.

Usage

1

Arguments

condition

the condition that is given

rv

the parameters we are entering

Value

the value of probability

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
f<- function(x) {ifelse(-1< x & x < 0, 3*x^2, 0)}
w=oneDSample1(f,50000,-1,0)
condition = function(x){x<-0.4}
probability(condition,w)

f<- function(x) {1/pi/(1+x^2)}
w=oneDSample1(f,50000)
condition=function(x){x<4.5}
probability(f,w)

f <- function(x){
x1 = x[1]
x2 = x[2]
ifelse(x2>0, 1/pi/(1+x1^2) * 0.05*exp(-0.05*x2), 0)}
w=twoDsample(f = f, N=10000)
condition = function(x,y){x<0.1 & y<2}
probability(condition,w)

jointPFF <- function(x){
x1 = x[1]
x2 = x[2]
ifelse(0<x1 & x1<1 & 0<x2 & x2<1 , 24*x1*x2, 0)}
w = twoDsample(f = jointPFF, N=10000)
condition=function(x,y){x<0.1 & y<2}
probability(condition,w)

zwang8889/project4800 documentation built on May 29, 2019, 12:20 p.m.