collecting mean and standard deviation at parameter values in a batch

45 views
Skip to first unread message

Chris Harvey

unread,
Apr 7, 2019, 5:05:15 PM4/7/19
to GAMA
I have a simulation design where I am collecting the mean and standard deviation of tarpon growth at a salinity. Within that salinity, I have a parameter "ExperimentalTemp" var: Monthly_waterTemp_Avg min: 28 max 31 step: 0.5 unit: "centimeter";

What I would like to do is collect the mean and standard deviation at each Salinity-Temperature combination. Right now, I'm only getting the mean and standard deviation for either the last of these temperatures or all of them averaged.

How can I do this?

Right now what I do is as follows:

experiment 'Run 1 Simulations' type: batch repeat: 1 keep_seed: true until: (cycle>6624)

parameter "ExperimentalTemp" var:Monthly_waterTemp_Avg min:28 max: 31 step: 0.5 unit: "centimeter";
float mean_N_Batch;
float sd_N_Batch;

reflex means_sds_calculations
{
int cpt <- 0;
loop t from: 0 to: (cycle=6624)
{
mean_N_Batch <- mean (simulations collect each.modeled_growth[t]);
sd_N_Batch <- standard_deviation(simulations collect each.modeld_growth[t];
save mean_N_Batch to: "../results/mean_N_Batch"+cpt+Monthly_waterTemp_Avg+".csv" type: "csv" rewrite: false;
save sd_N_Batch to:
"../results/sd_N_Batch"+cpt+Monthly_waterTemp_Avg + ".csv" type: "csv" rewrite: false;
cpt <- cpt+1;

}

}

Chris Harvey

unread,
Apr 7, 2019, 10:53:49 PM4/7/19
to GAMA

I would like to make a correction to what I had earlier - the standard deviation that is being produced is the same value as the mean. So, any ideas on why I am not getting standard deviations on a list of type float?

Benoit Gaudou

unread,
Apr 9, 2019, 11:41:02 AM4/9/19
to gama-p...@googlegroups.com
Hi,
Notice that you have repeat : 1 in your experiment statement.
As a consequence the lines : 
            mean_N_Batch <- mean (simulations collect each.modeled_growth[t]);
            sd_N_Batch <- standard_deviation(simulations collect each.modeld_growth[t];
compute mean and std dev on only 1 single simulation.
This could explain your issue ?

Cheers

Benoit

--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
To post to this group, send email to gama-p...@googlegroups.com.
Visit this group at https://groups.google.com/group/gama-platform.
For more options, visit https://groups.google.com/d/optout.

Chris Harvey

unread,
Apr 9, 2019, 8:22:02 PM4/9/19
to GAMA
Hi Benoit,

Yes _ set it to 1...I thought that the batch was taking the mean and standard deviation of the variable that I was giving it,  So, I have 45 agents of species Tarpon.  I read their final growth rates into a list and take the mean and standard deviation of that list.  My thinking is - the agents are independent, so they can be my statistical unit for replication.  But, I think the batch forces the run to be the statistical unit.  I've been thinking about this all day.  

So, I did a power analysis, and I need a sample size of 13.  I was hoping that I could do 1 run of more than 13 agents and collect the mean growth rate and standard deviation for those agents in that run.  My issue is, if I repeat for 13 times - the simulation takes many hours to complete..and I'm bumping up against my memory limits.  I set the seed to stay the same, but if I run half the simulations then run the other half, I would have different seed values wouldn't I?

I've since realized that I need to have more than 1 run to get standard deviation and that the reason I was getting a 0 is because I only had 1 run.

So - I'm struggling with this concept for the batch.  

Am I wrong with my understanding?  I'm looking for guidance here...I'm not sure of what I'm doing and everytime I run it, the simulation takes hours.

You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/O6L3S6-cAwI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.

Chris Harvey

unread,
Apr 10, 2019, 5:22:35 PM4/10/19
to GAMA
I think I found a solution to my problem.  I forgot that I can define the seed.  So I can define it run the number of repeats my computer can handle then keep the same value and run it as many times as I need.  Then just combine the outputs.

On Tue, Apr 9, 2019 at 10:41 AM Benoit Gaudou <benoit...@gmail.com> wrote:
You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/O6L3S6-cAwI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages