mercredi 22 mai 2019

SImulating Random numbers that are weibull distributed in Netlogo

I have been trying to get Netlogo to output random numbers according to a weibull distribution, given a scale and a shape as inputs. E.g, in R, the command rweibull does the trick, e.g, rweibull(1, shape=16, scale = 2500) outputs numbers like 2333.438, etc. However, the existing code that outputs a weibull distributed random variable in Netlogo (see code below) only produces numbers around 1, independently of the shape and scale that is entered. How can I get Netlogo to output a weibull distributed random variable as R does?

The existing Netlogo code I have tried is below(it is available on many sites)

If one tries to get the reporter to output a realization of the Weibull R.V using the same parameter as above, one only gets, e.g, 1.001021732652175, 1.000377358845726, and so on.

P.S: I have tried to use the rserve extension and use the r:get rweibull(n, shape, scale), but unfortunately the extension does not seem to be available for Netlogo 6.0 and above.

to-report random-weibull [#shape #scale] ; goes scale then shape
      let xWei random-float 1
      let yWei (1 / #scale)
      let zWei (#shape * (-1 * ln(1 - xWei)))^ yWei
      report zwei
    end

I expect the actual outcome of the reporter to be numbers around the scale that is used as input for the weibull reporter, and not a random float around 1 as it's doing now... Maybe another parameterization?




Aucun commentaire:

Enregistrer un commentaire