Here, you'll find practical implementations and exercises for the "Mathematical Modeling" course at Saint Petersburg Polytechnic University, led by instructor Leontyeva T.V.
- Numerical Integration.
- Coordinate Descent with Adaptive Step.
- Random Number Generator Verification.
- Parametric Model Identification.
This module implements functions for numerical integration using the 4th order Runge-Kutta method. It includes implementations of the algorithm for integrating first-order differential equations, saving the results to an Excel file, and plotting the results.
- numpy
- pandas
- matplotlib.pyplot
>>> t_values, y_values = numerical_integration(step=0.01, decimal_places=5, num_iterations=100)
>>> save_to_excel(t_values, y_values, "runge_kutta_results.xlsx")
>>> plot_results(t_values, y_values, "runge_kutta_plot.png")
numerical_integration(step, decimal_places, num_iterations)
: Performs numerical integration using the specified step size, number of decimal places, and iterations. Returns lists of t and corresponding y values.save_to_excel(t_values, y_values, filename="calculations.xlsx")
: Saves t and y values to an Excel file.plot_results(t_values, y_values, filename="plot.png")
: Plots the t and y values and saves the plot to a file.
This module contains functions for optimizing functions using the coordinate descent method with adaptive step. It includes implementations of the algorithm for ellipsoid and Rosenbrock function, as well as a function for saving results to an Excel file and plotting.
- math
- numpy
- pandas
- matplotlib.pyplot
>>> points, values = coordinate_adaptive_ellipsoid(1, 1)
>>> save_to_excel_and_plot(points, values, "ellipsoid_1_1")
coordinate_adaptive(function, step, init_point, inc_coef, dec_coef, epsilon, max_iter)
: Adjusts the adaptive step of coordinate descent.func_ellipsoid(x, y, A, B)
: Computes the values of the ellipsoid function.coordinate_adaptive_ellipsoid(A, B, initial_point=[-1, -1])
: Optimizes the ellipsoidal function using coordinate descent with adaptive step.rosenbrock(x, y)
: Computes the value of the Rosenbrock function.coordinate_adaptive_rosenbrock(initial_point)
: Optimizes the Rosenbrock function using coordinate descent with adaptive step.save_to_excel_and_plot(points, values, filename_prefix)
: Saves the coordinates of points and function values in an Excel file and plots a graph.
This module contains functions for verifying the built-in random number generator and a custom generator implemented using the Central Limit Theorem (CLT) method. It includes calculations of mean, variance, standard deviation, and the construction of a frequency diagram.
- random
- math
- matplotlib.pyplot
>>> verify_default_generator(100000)
>>> verify_cpt_generator(100000)
verify_default_generator(num_numbers)
: Verifies the built-in random number generator and displays statistics.verify_cpt_generator(num_numbers)
: Verifies the custom random number generator implemented using the Central Limit Theorem (CLT) method and displays statistics.cpt_generator()
: Generates a random number using the custom generator implemented using the Central Limit Theorem (CLT) method.plot_histogram(numbers, num_bins, r1, r2, title)
: Plots a frequency histogram for the given numbers.
numerical_integration
- Transition from transfer function to a differential equation and its solution using Euler's method. Output data (y(t)
- model).- Implementation of a custom random number generator using the Central Limit Theorem (CLT) method.
- Generating noise on the graph (adding noise to the output signal) - Experimental data.
- Forming the objective function (considering
b1
andb3
as unknowns). - Optimization method - coordinate descent with adaptive step (4 test points).
- numpy
- pandas
- matplotlib.pyplot
- random
- concurrent.futures.ThreadPoolExecutor