mercredi 8 décembre 2021

random numbers of a uniform distribution in R

I want to create random numbers of a uniform distribution, but I want to implement them with this function:

funcion.distribucion = function(x)
{
  L = length(x)
  F = vector("numeric",L)
  for (i in 1:L)
  {
    if (x[i]<0) { F[i] = 0}
    else if (x[i] <= 2) {F[i] = (x[i]^3)/8}
    else {F[i] = 1}
  }
  return(F)
}

runif(funcion.distribucion(200),0,1)

How I do it?




Aucun commentaire:

Enregistrer un commentaire