Message Boards Message Boards

0
|
2964 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

Running a simulation n times, saving the final outputs

Dear friends I have a code to make a simulation. Here it is a toy example represented by only two functions (the real code has more than 100 line an spend in my computer 10 minute each simulation)

data = RandomVariate[NormalDistribution[1, 3], 10^4];

mysolution = Mean[data] code here

I would like to run automatically n times (e.g.100) an save automatically each simulation (here mysolution). How can do it?

Thanks Guillermo

Posted 3 years ago

Hi Guillermo,

Something like this?

generateData[] := RandomVariate[NormalDistribution[1, 3], 10^4]
computeSolution[data_] := Mean[data]

Table[computeSolution[generateData[]], 10]
(* {0.98648, 1.0595, 1.03899, 0.965868, 1.0184, 1.0489, 1.03447, 1.01172, 0.97868, 1.02466} *}
POSTED BY: Rohit Namjoshi
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