This is my code below and all I get is a list of the same values and it doesn't seem like R is taking a randomly generated value, running through the equation and then giving me the results. montecarlo = function(r,v,t,x,k,n) { y=rnorm(n) stockprice = x*exp((-v*sqrt(t)*y)+((r-(.5*v^2))*t)) MCOP=exp(-r*t)*(stockprice-k) return(MCOP) }
The output for this code is just a single value 100 times if I set n = 100
Aucun commentaire:
Enregistrer un commentaire