Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

I'm trying to find out how some value is calculated in some strategy game. I know the variables that make that value, but not how they are combined to make it. So I gathered some samples:

  • c=100 when a=32 and b=1
  • c=7 when a=2 and b=1
  • c=391 when a=32 and b=12
  • c=781 when a=64 and b=12

c is the value I'm trying to find the formula of, and a and b are the only variables in that formula (that are changing between sample to sample). What makes it all harder is that c is rounded either up or down.

I guessed few formulas myself, none applied to all samples. Then I thought there must be a program that could let me enter these samples and estimate a formula for me, but not found such.

Am I in the right direction? is it even possible to do something with such samples?

share|cite|improve this question
up vote 1 down vote accepted

You might try a least-squares fit to some simple form. Without any more information about the sorts of formulas that might be appropriate, I might try $c = p_0 + p_1 a + p_2 b$, which gives not too bad a fit. You gave only four data points, so a form with four degrees of freedom should provide an exact fit, e.g. $c = {\frac {43}{55}}+{\frac {2001}{880}}\,a+{\frac {1}{55}}\,b+{\frac {727 }{880}}\,ab$

share|cite|improve this answer
Thanks! The form with four degrees of freedom truly provides exact fit and very close fit to new samples. I'll be happy to know how to reproduce it with additional samples; which method should I learn to do that? – Moshe Revah May 30 '12 at 21:22
Linear least squares. See – Robert Israel May 30 '12 at 21:29
Oh. Thought the second form was not related to least-squares. Thanks. – Moshe Revah May 30 '12 at 21:43

Have you tried to use Interpolation?

share|cite|improve this answer

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.