Skip to content
Advertisement

Generating 1000 iterations

I am trying to generate 1000 sets of data points using fake_exp_y_values generator. All I am trying to do is to calculate the chi2 values for all 1000 iterations with different fitting models. But the way I code it right now only gives me back one chi2 value. I don’t understand what is wrong.

Here is my code:

JavaScript

Yet the returned chi2 list is:

result

Advertisement

Answer

This code 1000 times creates an array with 1000 zeros and inserts one value in each of them, but only keeps the last one:

JavaScript

You only want to create one array and use it in every one of the 1000 iterations:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement