I have a function x that is dependent on a random variable s, where s =randn(1,1) the function x=x+s , where x will be replaced by the new value everytime the loop runs i need to create a loop script that when x is less/equal to -10 or more/equal to 10, it will stop and calculate how many times the loop has ran. I then need to run this loop in a loop 100 times and calculate the average number of times the loop ran to hit the 10/-10 condition in a total of 100 times. My script looks like this with alot missing:
x=0;step=0;while (x<10)&&(x>-10) s=randn(1,1); x=x+s; step=step+1end
Best Answer