Difference between revisions of "Modeling"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
Mostly based on [http://greenteapress.com/ModSimPy/ModSimPy.pdf this paper] that comes with its own modsim library. | Mostly based on [http://greenteapress.com/ModSimPy/ModSimPy.pdf this paper] that comes with its own modsim library. | ||
− | + | * A model depicts a system. | |
− | * | + | * The state of the system attributes is stored in a [[Pandas#Series]] |
− | + | * Results of how the system attributes change over time are stored in Pandas Series too (1 Series per attribute). | |
− | + | * Parameters that determine how the system attributes change are stored in a [[Python:DataTypes#Dictionary_or_dict|dictionary]] or also in a pandas series. | |
− | + | * The functions that change the system attributes take the system parameters as parameter. This way you can play with the parameter values to get the best result. | |
− | + | * [[Numpy#linspace]] provides an equally distributed range of values so you can play easily between the limits you set. | |
− | + | * The quality of the model can be judged by calculating the relative error of the [[Approximation]] | |
− | + | ||
− | * The | + | =Other remarks= |
− | |||
* If you use randomness in a function, get the mean values of several runs. | * If you use randomness in a function, get the mean values of several runs. | ||
− | + | ||
+ | =Example code= | ||
+ | [[Numpy]] [[Numpy#linspace | linspace]] | ||
<syntaxhighlight lang=python> | <syntaxhighlight lang=python> | ||
funcAresults = pd.Series([]) | funcAresults = pd.Series([]) | ||
Line 21: | Line 22: | ||
print(funcAresults) | print(funcAresults) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ||
− | + | Store results in a [[Pandas]] [[Pandas#Series|Series]] | |
<syntaxhighlight lang=python> | <syntaxhighlight lang=python> | ||
− | + | for a in range(100): | |
+ | funcAresults[a] = functionAcall(bla,bla) | ||
+ | funcBresults[a] = functionBcall(bla,bla) | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 14:36, 25 December 2018
Mostly based on this paper that comes with its own modsim library.
- A model depicts a system.
- The state of the system attributes is stored in a Pandas#Series
- Results of how the system attributes change over time are stored in Pandas Series too (1 Series per attribute).
- Parameters that determine how the system attributes change are stored in a dictionary or also in a pandas series.
- The functions that change the system attributes take the system parameters as parameter. This way you can play with the parameter values to get the best result.
- Numpy#linspace provides an equally distributed range of values so you can play easily between the limits you set.
- The quality of the model can be judged by calculating the relative error of the Approximation
Other remarks
- If you use randomness in a function, get the mean values of several runs.
Example code
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)
Store results in a Pandas Series
for a in range(100):
funcAresults[a] = functionAcall(bla,bla)
funcBresults[a] = functionBcall(bla,bla)