avhz / RustQuant

Rust library for quantitative finance.
https://docs.rs/RustQuant
Apache License 2.0
969 stars 105 forks source link

Fixed the exponential interpolator #235

Closed MeetThePatel closed 2 weeks ago

MeetThePatel commented 2 weeks ago

Fixed the exponential interpolator.

https://github.com/avhz/RustQuant/pull/162#issuecomment-1926279538

One of the changes was in the actual computation to the exponential interpolation. I'm not too sure how your method previously worked, but the following method is quite straightforward, and it seems to fix the issue.

Method:

  1. Starting with (x_1, y_1) and (x_2, y_2) and we want to interpolate at some point x_1 < p < x_2.
  2. Take the log of the y-values. That is, we now have (x_1, ln(y_1)) and (x_2, ln(y_2)).
  3. Use linear interpolation between these two points.
  4. Apply exp to it to convert back out of logspace.
avhz commented 2 weeks ago

Awesome, thanks for this one !