Hey guys,
I've written a code like this. Everything is fine except I don't know how to calculate the mean of x(i) values at the end (I get errors when I put it in different places of my code!). Could any of you help me please? Here is the code (I want to calculate 1000 numbers, let's call them x(1), x(2), … and finally take the average):
clc;clear;syms fS fR k Alpha uR uS yN = 1000; mu = 16;sigma = 25;uR = 20;uS = 10;Alpha = 12.153;k = 6.010;VR = 0.1;VS = 0.25;mu_R = uR * gamma (1 + 1/Alpha);mu_S = uS * gamma (1 - 1/k);SD_R = mu_R * VR;SD_S = mu_S * VS;fS == ((k/uS)*(uS/y)^(k+1))*exp(-(uS/y)^k);fR == (Alpha/uR)*((y/uR)^(Alpha-1))*exp(-(uS/y)^k);for i=1:N R(i) = (mu_R + SD_R*rand()); S(i) = (mu_S + SD_S*rand()); hR(i) = normpdf(R(i), mu, sigma); hS(i) = normpdf(S(i), mu, sigma); h(i) = hR(i)*hS(i); fS(i) = 0.601*exp(-1.0*(10.0/S(i))^(601/100))*(10.0/S(i))^(701/100); fR(i) = 0.60765*exp(-1.0*(10.0/R(i))^(601/100))*(0.05*R(i))^(11153/1000); fRS(i) = fR(i)*fS(i); if (R(i)<S(i)) I(i)=1; x(i) = (I(i)/h(i))*fRS(i); endendPf = mean(x)
Thank you!
Best Answer