NAVER

질문 몬테카를로 시뮬레이션
jjk7**** 조회수 5,451 작성일2014.06.03
Consider the lattice points (points with integer coordinates) in the square  0<=x<=6, 0<=y<=6. A particle starts at the point (4,4) and moves in the following way: At each step it moves with equal probability to one of the four adjacent lattice points. what is the probability that when the particle first crosses the boundary of the square, it crosses the bottom side? Use Monte Carlo simulation.  이문제를 몬테카를로 시뮬레이션 을 이용해서 풀고싶은데 어떻게 해야될까요?? .. 시작도 못하겠네요 ..도와주세요
프로필 사진

답변자님,

정보를 공유해 주세요.

1 개 답변
1번째 답변
프로필 사진
sos440
태양신
수학 25위 분야에서 활동
본인 입력 포함 정보
어떤 언어를 사용하느냐에 따라 시뮬레이션이 많이 달라지겠지요?

예를 들어 매쓰매티카로 시뮬레이션 한다고 하면




와 같이 할 수 있고, 자바스크립트로 시뮬레이션한다고 하면

// Create an instancefunction Variate(){        var iX = 4, iY = 4;        while (true){                // Move one step                switch ((Math.random() * 4) >> 0){                case 0:                        iX += 1;                        break;                case 1:                        iY += 1;                        break;                case 2:                        iX -= 1;                        break;                default: // Both deals with the case 3 and the very rare exceptional case 4                        iY -= 1;                }                // Test if the particle hit the boundary                if (iX == 0 || iY == 0 || iX == 6 || iY == 6){                        return { x : iX, y : iY };                }        }}var oInst; // Instance for each simulationvar iCnt = 0; // Count of instances where particle hit the bottomfor (var iN = 0; 1000000 > iN; iN++){        oInst = Variate();        if (oInst.y == 0){                iCnt++;        }}WScript.Echo(iCnt / iN);

와 같이 시뮬레이션할 수도 있습니다. (출력 부분이 윈도우의 자바스크립트 콘솔 버전으로 되어 있으므로, 웹이나 기타 다른 곳에서 돌리려면 해당 부분을 알맞게 고치시면 됩니다.)

2014.06.03.

  • 채택

    질문자가 채택한 답변입니다.

도움이 되었다면 UP 눌러주세요!
UP이 많은 답변일수록 사용자들에게 더 많이 노출됩니다.