Changes

Using Python to Create Functions, Models & Scripts

248 bytes added, 04:51, 6 September 2016
/* What Can You Do with Your Python Models? */
In the case of optimization, you must enter '''Min''' and '''Max''' values for the optimization variable as well as a '''Target''' value for your Python function. Select and highlight the name of your Python function from the list and click the {{key|Optimize}} button to run the optimization. An objective function of the form e(x) = |func_name(x) - Target| is constructed and minimized. After the optimization algorithms converges, the optimal value of x and the optimization error are reported in the command window.
 
<table>
<tr>
<td>
[[Image:PY MAN6.png|thumb|left|480px|The command window showing the results of optimizing "MyFunc(x)" with a target value of 0.5 over the interval [0, 10]. The optimal value is reported to be x = 0.415083.]]
</td>
</tr>
</table>
In the case of Monte Carlo simulation, you must enter values for '''Mean''' and '''Std Dev''' of the sweep variable as well as '''Number of Samples'''. Select and highlight the name of your Python function from the list and click the {{key|Monte Carlo}} button to run the simulation. Through this process, the probability density function (PDF) of your observable y = func_name(x) is estimated, and its graph is plotted as a function of y in EM.Grid. The mean and standard deviation of y are also reported in the command window.
28,333
edits