#' revision du tp
#' @export
#'
#' @param x les etats
#' @param p les proba
rdist<-function(x,p)
{
n=length(p)
r=runif(1)
b=p[1];
if((r>=0) & (r<=b))
{
y=x[1]
return(y)
}
else
{
a=p[1]
b=b+p[2]
for(i in 2:n)
{
if((r>=a) & (r <=b))
{
y=x[i]
return(y)
}
else
{
a=b
b=b+p[i+1]
i=i+1
}
}
y=x[n]
return(y)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.