필터 지우기
필터 지우기

Using a triangular distribution in a Monte Carlo simulation

조회 수: 4 (최근 30일)
Rabia Sonmez
Rabia Sonmez 2021년 9월 25일
편집: Image Analyst 2021년 9월 25일
Hello everyone. I am trying to simulate Monte Carlo analysis using a triangular distribution. I have 10 different subassemblies with its min, max, and best values. I put them into a matrix, as shown below. The first row of the matrix represents subassembly 1 and second row is subassembly 2 and it goes like this. I've chosen random numbers from all different subassemblies, and I sum these numbers. But I want to do this 1000 times, so it should give 100 results. But I could not put it into code. Please help!! Thank you
clear all
clc
sub=[97 122 185;56 68 98;143 164 225;29 33 48;68 74 96;131 147 194;107 132 178;41 46 62;69 81 117;58 63 92];
sum=0;
ntime=3;
for i=1:10
b(i,:)=randi([min(sub(i,:)),max(sub(i,:))],1);
sum=sum+b(i,:);
end
  댓글 수: 1
Image Analyst
Image Analyst 2021년 9월 25일
sum is a built-in function so you should not use it as the name of your variable.
If you want to do that 10-iteration for loop 1000 times (or 100 times), just put it inside another for loop where you loop 1000 times (or 100 times).

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by