Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have an algorithm for calibrating an O2 (oxygen) sensor I'm trying to get my head around. The original author is gone and away and the whole thing seems to generally work, but I'd like to verify that it's working correctly. (And testing it at known points is uh, hard.)

Here it is:

$$ TargetValue = MeasuredValue * \frac{ln(1-TargetPercentage)}{ ln(1-MeasuredPercentage)} $$

We have a MeasuredValue we get when we put O2 gas across our sensor at 20%, MeasuredPercentage. But we actually want a reading at 10% O2 gas, TargetPercentage. Which, according to the algorithm when the target is 0.1 and the measured is 0.2, means we multiply all those readings by 0.47.

We use the 'MeasuredValue' as a calibration point so the variance across O2 sensors is removed. The code assumes a calibration point of 10% O2, while the actual gas we feed it consists of 20% O2.

The algorithm is pasted all over the place, but the target and measured percentages are the same, and it all cancels out. Except for at 20%, which is "adjusted" to 10%. In which case the algorithm simplifies to $$ TargetValue = MeasuredValue*0.47 $$

The question becomes why 0.47?

This O2 sensor's output follows a curve. As the O2 increases it outputs higher voltage at an exponential rate. This looks like the author is trying to perform exponential interpolation to take a value they got at 20%, and shift it down an exponential curve to 10%. But it's not exactly the same as what I've been able to research, like:

$$ y = exp[ln(y_{i-1}) + [ln(y_i)-ln(y_{i-1})]\frac{x-x_{i-1}}{x_i-x_{i-1}} $$

I can't see how this algorithm would transform into the one that's being used.

Is this an algorithm for exponential interpolation?
If not, what is it doing?

share|cite|improve this question

It seems to me that what is going on is not interpolation, but an expression of a relationship of the form

$$v(p) = k \ln{(1-p)}$$

The measured values provide the value of $k$ ($0.47$ in your example), and you take it from there for $p=0.1$. I don't see a relation between this and any sort of interpolation. For small $p$, perhaps you can get away with linear interpolation, but that's about all.

share|cite|improve this answer
The 0.47 value comes from a case when the percentage variables are at fix points. Then the relationship between the measured and target values is just f(x)=y*0.45. But, you know... why? – Philip Jul 9 '13 at 15:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.