Optimize with optimization rather than inverse conversion

A program is written because there is something you want to achieve (or something you are requested to achieve). Therefore, it is important to increase your understanding of what you want to achieve. Whatever the development language, it's worth knowing what you want to achieve with a wealth of tools. Recently, I used Python's SciPy library to match parameters in data analysis. Optimization (scipy.optimize)

If you use the simplex method, you don't need to find the inverse conversion of the calculation formula, and it is easy to handle when the numerical value contains an error. (Of course, to reduce the effect of error, it is necessary to have more experimental data than unknown degrees of freedom.) Derivation by hand is troublesome to obtain the formula for inverse transformation, and depending on the value of the parameter, the denominator may be close to 0 and the calculation accuracy may not be high. Even if the number of experimental data is larger than the unknown number, there is a drawback that not all of them can be used.

The Simplex method is one of the algorithms that minimizes functions with many parameters. In the olden days, [Japanese version of "Numerical Recipes in C"](http://www.amazon.co.jp/%E3%83%8B%E3%83%A5%E3%83%BC% E3% 83% A1% E3% 83% AA% E3% 82% AB% E3% 83% AB% E3% 83% AC% E3% 82% B7% E3% 83% 94% E3% 83% BB% E3% 82% A4% E3% 83% B3% E3% 83% BB% E3% 82% B7% E3% 83% BC-% E6% 97% A5% E6% 9C% AC% E8% AA% 9E% E7% 89 % 88% E2% 80% 95C% E8% A8% 80% E8% AA% 9E% E3% 81% AB% E3% 82% 88% E3% 82% 8B% E6% 95% B0% E5% 80% A4 % E8% A8% 88% E7% AE% 97% E3% 81% AE% E3% 83% AC% E3% 82% B7% E3% 83% 94-William-H-Press / dp / 4874085601) I remember porting the algorithm to another language and using it. In the case of MATLAB, the algorithm for minimizing the function is enriched in Optimization Toolbox. When I used MATLAB for business, I realized the convenience of numerical analysis with an interpreter. Now that the Python environment represented by Spyder (an example of a commentary blog) is substantial There is no point in writing using the highly licensed MATLAB. Of course, if you like MATLAB, go to home license). Since it is cheap to use, it is also possible to use it at home. (In the field of model-based design, Simulink has become the de facto standard in some industries, and we also know the benefits it brings.)

If you verify the operation using Python, it is easy to verify the algorithm. Python is easy to use, and the graph library matplotlib, which is similar to MATLAB, can be used, so it is easy to check the results. Besides that, in Python, after using it enough, you can quickly write and try what the argument of the function should be, so use whether it should be implemented as a single function or as a method of the class. You can verify while. If you implement it in C ++ based on the result, you can greatly reduce mistakes in designing in C ++. I find it rather awkward to port another version of a library written in C ++ to a program under development.   After all Python is fun

Recommended Posts

Optimize with optimization rather than inverse conversion
[Part.3] Crawling with Python! It's JSON rather than CSV! ??
Road installation with optimization
Getting Started with Optimization