Difference between revisions of "Modeling"

From wiki
Jump to navigation Jump to search
Line 20: Line 20:
 
         funcAresults[a] = functionAcall(p1,p2)
 
         funcAresults[a] = functionAcall(p1,p2)
 
     print(funcAresults)
 
     print(funcAresults)
 +
</syntaxhighlight>
 +
* The [https://en.wikipedia.org/wiki/Approximation_error Approximation error] ([https://nl.wikipedia.org/wiki/Benaderingsfout benaderingsfout]) is the difference between a calculated value and the real value. By dividing it by the real value you get the relative error. A bit relative error indicates bad calculation.
 +
The largest relative error between two arrays as percentage:
 +
<syntaxhighlight lang=python>
 +
max(abs(calculated - real) / real ) * 100
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 22:10, 24 December 2018

Mostly based on this paper that comes with its own modsim library.

Eyeopeners

  • Store results in a list
for a in range(100):
    funcAresults[a] = functionAcall(bla,bla)
    funcBresults[a] = functionBcall(bla,bla)
ModSimPy is using Series from Pandas to store results. This adds handy functions like.
  • The state of the model is stored in a Pandas Series too.
  • Put other interesting metrics in the state object too.
  • If you use randomness in a function, get the mean values of several runs.
  • Check the effect of different parameter values using Numpy linspace.
funcAresults = pd.Series([])
p1_array = np.linspace(0,1,12)
for p1 in p1_array:
    for a in range(50):
        funcAresults[a] = functionAcall(p1,p2)
    print(funcAresults)
  • The Approximation error (benaderingsfout) is the difference between a calculated value and the real value. By dividing it by the real value you get the relative error. A bit relative error indicates bad calculation.

The largest relative error between two arrays as percentage:

max(abs(calculated - real) / real ) * 100