Description Usage Arguments Value Examples
View source: R/conditional probability.R
The goal of the function is used to compute the probability of the given ramdon variables.
1 | probability(condition, rv)
|
condition |
the condition that is given |
rv |
the parameters we are entering |
the value of probability
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.