필터 지우기
필터 지우기

Help with Monte Carlo sim?

조회 수: 1 (최근 30일)
Taylor Gates
Taylor Gates 2018년 7월 23일
답변: Image Analyst 2018년 7월 23일
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=

채택된 답변

Image Analyst
Image Analyst 2018년 7월 23일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by