Effacer les filtres
Effacer les filtres

Help with Monte Carlo sim?

2 vues (au cours des 30 derniers jours)
Taylor Gates
Taylor Gates le 23 Juil 2018
Im messing around with the montecarlo function for integration and ran into a problem. The y bounds are between x^2 and x^3 and x are between 0 and 1. Heres the code I have so far but can't figure out how to deal with the y bounds.
N=1000; Landed=0;
for i=1:N x=rand()*1; y=rand()* Landed=Landed+1 end disp('Calculated Area Size:') area=

Réponse acceptée

Image Analyst
Image Analyst le 23 Juil 2018
That code won't even run. Even if it did, your x and y are just rand() which goes between 0 and 1. The y bounds have nothing at all to do with x, x^2 or x^3, but since they all use rand, everything will be between 0 and 1. If you want some higher value, multiply rand() by some amplification factor.
I'm attaching my Monte Carlo demos, for what it's worth.

Plus de réponses (0)

Catégories

En savoir plus sur Monte-Carlo dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by