This project solves a parametric curve fitting problem to find unknown parameters in a complex parametric equation. The goal is to fit observed data points to a parametric curve and determine the optimal values for three unknown parameters: θ (theta), M, and X.
Given the parametric equations:
$x = t \cdot \cos(\theta) - e^{M|t|} \cdot \sin(0.3t) \cdot \sin(\theta) + X$ $y = 42 + t \cdot \sin(\theta) + e^{M|t|} \cdot \sin(0.3t) \cdot \cos(\theta)$
Where:
-
Unknown parameters:
$\theta$ (0° < θ < 50°),$M$ (-0.05 < M < 0.05),$X$ (0 < X < 100) -
Parameter range:
$t \in (6, 60)$ - Input data: 27.4 KB of observed (x, y) points lying on the curve
Find the optimal values of θ, M, and X that best fit the observed data points, minimizing the distance between the predicted curve and the observed points.
\left(t\cdot\cos(\pi/6) - e^{0.03\left|t\right|}\cdot\sin(0.3t)\sin(\pi/6) + 55, 42 + t\cdot\sin(\pi/6) + e^{0.03\left|t\right|}\cdot\sin(0.3t)\cos(\pi/6)\right)Or in decimal form:
\left(t\cdot\cos(0.523599) - e^{0.03\left|t\right|}\cdot\sin(0.3t)\sin(0.523599) + 55, 42 + t\cdot\sin(0.523599) + e^{0.03\left|t\right|}\cdot\sin(0.3t)\cos(0.523599)\right)Where:
- θ = 0.523599 radians = π/6 radians = 30°
- M = 0.03
- X = 55
- L1 Distance: 0.027621
The explanation of the solution will be found in EXPLANATION.md
pip install -r requirements.txtpython src/solution.pyor
Open src/solution.ipynb and run each cell
python src/test_parameters.py.
├── README.md # This file
├── SOLUTION.md # Detailed solution explanation
├── requirements.txt # Python dependencies
├── data/
│ └── xy_data.csv # Given data points
├── src/
│ ├── solution.py # Python solution script
│ └── test_parameters.py # Post-optimization parameter testing
│ └── solution.ipynb # Jupyter notebook with interactive analysis
└── results/
├── solution.txt # Solution output
└── figures/ # Generated visualizations
├── fitted_curve_vs_observed.png
├── parametric_curve_analysis.png
├── parameter_comparison.png
└── comparison_User_Test_(θπ6,_M0.03,_X55).png
The solution generates the following visualizations:
- Overlay of predicted curve and observed points
- Visual validation of curve fit quality
- Distance Distribution: Histogram of point-to-curve distances
- Parametric Components: x(t) and y(t) over parameter range
- Residual Plot: Distance vs. parameter t
- Exponential Modulation: Visualization of e^(M|t|)·sin(0.3t) term
- Generated by
test_parameters.py - Compares user-provided test parameters with optimal solution
- Shows fit quality across different parameter sets
- Detailed comparison visualization for specific test parameters
- Shows both curves overlaid with observed data
All figures are saved in results/figures/.
This project is for assessment purposes.