Message Boards Message Boards

0
|
5065 Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Mean of the result of iterations...

Posted 10 years ago
Table[r = Print[100*Log[(-1)/(RandomReal[] - 1)]], {i, 100}]

OR

Do[r = Print[100*Log[(-1)/(RandomReal[] - 1)]], {i, 100}]

I get 100 iterations of this expression. I need to find the mean/average of these iterations. How can I do this?

POSTED BY: Fat Villager
6 Replies
Posted 10 years ago

Beautiful! Thank you.

POSTED BY: Fat Villager
Posted 10 years ago

But

RandomReal[1, 100]

returns 100 random numbers between 0 and 1.

RandomReal[{1, 100}]

returns a single random number between 1 and 100.

POSTED BY: Jim Baldwin
Posted 10 years ago

Jim, thanks for your response. The RandomReal[] should be a random number between 0 and 1, not 1 and 100.

My idea is this:

I have an expression 100*Log[(-1)/(RandomReal[] - 1)]

I want to solve this 100 times, using a random real number between 0 and 1 each time.

Then I will get 100 values of r = 100*Log[(-1)/(RandomReal[] - 1)], and then I have to calculate the mean of all of these values.

POSTED BY: Fat Villager
Posted 10 years ago

If the "100" of "100 iterations" is the same as the "100" in {i,100}, then the following will get you the mean:

Mean[100 Log[-1/(RandomReal[1, 100] - 1)]]

Or are there 100 iterations of the 100 random draws?

POSTED BY: Jim Baldwin
Posted 10 years ago

Picture of what's going on...enter image description here

POSTED BY: Fat Villager
Posted 10 years ago

So whenever I do Table[r = Print[100*Log[(-1)/(RandomReal[] - 1)]];, {i, 100}] I get the result of each iteration one by one, but then at the end I get the list with {Null, Null, Null, Null, etc...}. Why is this?

POSTED BY: Fat Villager
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract