Package: regularization-derivative
regularization_derivativeThis package is supposed to be used to find derived data with errors. It allows you to find derivatives of data using the regularization method and errors of derivatives using the Monte Carlo method.InstallationThis package is to be used with Python 3.x.xTo install the package writepipinstallregularization-derivativeUsageTo use the package in your project, import it in by writingfromregularization_derivativeimportregularization_derivativeParameters of the functionregularization(height, t_height, err_height, alpha, ord, print_parameters=True, mk=False, num_mk=100)Based on a set of coordinates of points and errors, it obtains the coordinates of points of derivatives by the regularization method, as well as the errors of these points by the Monte Carlo method.Parameters:height:array_likeArray of y-coordinates of points by which the derivative will be calculatedt_height:array_likeArray of x-coordinates of points by which the derivative will be calculatederr_height:array_likeArray of error y-coordinates of points by which the derivative will be calculatedalpha:floatRegularization parameterord:int (1, 2 or 3)Order of differentiation operatorprint_parametrs:booleanDisplays the parameters needed to select the regularization parameteralphamk:booleanCalculates the errors of the obtained points-derivatives by the Monte Carlo methodnum_mk:intNumber of iterations in the Monte Carlo methodRecommendations for useSelection of the regularization parameteralphaThe main problem of using this method is the selection of thealphaparameter.
To choose it correctly, you need to look at the value indicated in the program asquotient$$
quotient = \frac{| A \vec{u} - \stackrel{\wedge}{y} |^2}{| \delta y | ^2}
$$In theory, the optimal value of the above expression is equal to one. But in practice it is often difficult to obtain such an ideal case, and sometimes it is not only impossible, but also unnecessary. In this case, you should be guided by the principle:Note:
The closerquotientis to zero, the better the resulting curve will fit the data. The closerquotientis to one, the smoother the resulting curve will be.Warning:alphafor any particular task can be very different from about1e1to1e20, so when choosing, first determine the power.Choice of the order of the differentiation operator ordAs part of our task, we wanted to obtain a smooth acceleration function from the distance versus time data. The curve is smooth if the function has a continuous derivative, then in our case the order of the differentiation operatorordis 3, since the acceleration is the second derivative of the coordinate, and it must be smooth. Accordingly, to speed up the order of the differentiation operatorord = 2.Using the Monte Carlo methodThe regularization method is not provided with tools for estimating the errors of derivatives, so the Monte Carlo method was used for these purposes. To use it a large number of times, a set of points is created for the distance within the error limits, and then the speed is calculated by the regularization method.To use it, you need to set the function parametersmk = Trueand set the number of iterationsnum_mkWarning:
Due to the peculiarities of the method of searching for smooth functions, the errors on the "tails" are much larger than in the middle. If you have a lot of points, then you can remove such points at the ends from consideration, since their errors will be somewhat overestimated.Examples of usingExamples of using the code on mathematical functions and on solar events can be viewed ongithub.