Skip to content

Parametric Curve Fitting for Flam R&D AI Assignment — Optimization of θ, M, X using L1 Distance Minimization

Notifications You must be signed in to change notification settings

karthixcarlo/Flam-RnD-AI-Assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flam Research & Development / AI — Assignment Submission

Objective

The objective of this assignment is to determine the unknown variables — rotation angle (θ), exponential rate (M), and offset (X) — for a given parametric curve model that best fits the observed dataset.
The fitting accuracy is evaluated using the L1 distance metric between predicted and observed data points.


Problem Definition

Given the parametric model:

[ x(t) = t\cos(\theta) - e^{M|t|}\sin(0.3t)\sin(\theta) + X ] [ y(t) = 42 + t\sin(\theta) + e^{M|t|}\sin(0.3t)\cos(\theta) ]

where ( t \in [6, 60] )

Unknown variables:

  • ( \theta ): rotation angle
  • ( M ): exponential modulation rate
  • ( X ): horizontal translation offset

Constraints: [ 0° < \theta < 50°, \quad -0.05 < M < 0.05, \quad 0 < X < 100 ]


Model Interpretation

The given equations represent a rotated and amplitude-modulated sinusoidal curve.

  • ( \theta ) controls the rotation (orientation of the wave).
  • ( M ) influences exponential damping or amplification.
  • ( X ) translates the curve horizontally to align with the dataset.

The goal is to estimate these parameters so that the model matches the provided coordinates with minimal deviation.


Step 1: Initial Visualization

The dataset (xy_data.csv) was plotted to inspect its behavior.
Observation revealed:

  • The curve was slightly inclined (~30°).
  • A mild exponential growth pattern.
  • Center offset around ( X ≈ 55 ).

Hence, visual inspection suggested initial guesses near: [ \theta_0 ≈ 0.52 \text{ rad}, \quad M_0 ≈ 0.03, \quad X_0 ≈ 55 ]


Step 2: Desmos Visualization

A parametric representation was created in Desmos using sliders for easy adjustment:

x(t) = tcos(a) - e^(mabs(t))sin(0.3t)sin(a) + X y(t) = 42 + tsin(a) + e^(m*abs(t))sin(0.3t)*cos(a) By tuning the sliders, the following configuration produced an excellent visual match:

𝑎

0.5236 , 𝑚

0.03 , 𝑋

55 a=0.5236,m=0.03,X=55

These visually consistent values were used as initialization for refinement.


Step 3: Numerical Refinement in Python

To fine-tune parameters, a numerical optimization process was implemented using iterative L1-distance minimization.

Steps followed:

  1. Generated 1000 uniform t samples between 6 and 60.
  2. Computed predicted (x, y) for each candidate parameter set.
  3. Used KDTree mapping to find nearest distances between predicted and actual data points.
  4. Summed all distances to compute L1 loss.
  5. Adjusted θ, M, and X iteratively to minimize this loss.

Step 4: Optimized Parameters

Parameter Symbol Final Value
Rotation Angle θ 0.5236177 rad
Exponential Rate M 0.0300005039
Offset X 55.00333601

These final values were consistent across both visual and numerical evaluations.


Step 5: L1 Metric Evaluation

The L1 distance was chosen to evaluate the point-wise deviation:

[ L_1 = \sum_i | (x_i, y_i) - (\hat{x}_i, \hat{y}_i) | ]

Metric Value
L1 Total Distance 5.5507
L1 Mean Distance 0.0037

A mean deviation of 0.0037 units indicates near-perfect curve reconstruction.


Step 6: Final Fitted Equation

[ \left( t\cos(0.5236177) -e^{0.0300005039|t|}\sin(0.3t)\sin(0.5236177) +55.00333601,; 42+t\sin(0.5236177) +e^{0.0300005039|t|}\sin(0.3t)\cos(0.5236177) \right) ]


Step 7: Desmos Interactive Validation

Open Interactive Graph

How to verify:

  • Adjust sliders a, m, and X to validate visually.
  • Black points = dataset (xy_data.csv)
  • Red/green curve = model prediction

Visual confirmation shows both curves overlap perfectly for all t.


Step 8: L1 Error Visualization

The error between predicted and actual points was plotted as:

[ \text{Error}(t) = |y_{\text{true}}(t) - y_{\text{pred}}(t)| ]

The graph indicated negligible deviations (below 0.004), confirming quantitative and visual consistency.


Step 9: Summary of Workflow

Stage Description
Data Loading Extracted from xy_data.csv
Visualization Desmos-based parametric plotting
Initial Estimation Visual slider tuning
Optimization L1 minimization using KDTree mapping
Validation Overlay comparison and L1 metric
Reporting LaTeX-formatted documentation and README

Step 10: Interpretation

  • θ ≈ 30° defines the rotation angle of the wave pattern.
  • M = 0.03 introduces controlled exponential damping.
  • X = 55 positions the wave correctly along the x-axis.

Together, these yield a highly accurate, physically interpretable model fit.


References

  1. Boyd, S. & Vandenberghe, L. (2004). Convex Optimization. Cambridge University Press.
  2. Nocedal, J. & Wright, S. (2006). Numerical Optimization. Springer.
  3. MathWorks. “Nonlinear Curve Fitting Techniques.” MATLAB Documentation.
  4. Weisstein, E. W. “Parametric Equations.” MathWorld – Wolfram Web Resource.
  5. Desmos Graphing Calculator — https://www.desmos.com

Academic Integrity Statement

All work presented in this report was manually conducted, including:

  • Equation derivation
  • Parameter tuning
  • Code implementation
  • Error computation

The results reflect original analysis and understanding of numerical modeling.


Author’s Note

This submission highlights a complete workflow — from visual approximation to numerical optimization — demonstrating practical knowledge of:

  • Mathematical modeling
  • Parametric curve fitting
  • L1 metric evaluation
  • Visual validation techniques

Such skills are directly applicable to AI-driven R&D processes involving predictive modeling.


Submitted by:
Karthigai Selvam R
Department of Computer Science and Engineering (AI)
Amrita Vishwa Vidyapeetham — Coimbatore Campus
Flam R&D / AI — Campus Placement Assignment

About

Parametric Curve Fitting for Flam R&D AI Assignment — Optimization of θ, M, X using L1 Distance Minimization

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published