tags:

views:

207

answers:

6

I'm not sure if this can be done without some determining factor....but wanted to see if someone knew of a way to do this.

I want to create a shifting scale for numbers.

Let's say I have the number 26000. I want the outcome of this algorithm to be 6500; or 25% of the original number. But if I have the number 5000, I want the outcome to be 2500; or 50% of the original number.

The percentages don't have to be exact, this is just an example.

I just want to have like a sine wave sort of thing. As the input number gets higher, the output number is a lower percentage of the input.

Does that make sense?

+3  A: 

Plot some points in Excel and use the "show formula" option on the line.

Joe Philllips
Excel will (probably) use polynomial interpolation and these techniques don't provide good (or rather, anything close to reasonable) asymptotic behaviour. The description of the problem suggests that this is necessary. To add another possibility to the ones already given: the reciprocal. Using the correct weights it might be a useful approach :).
Pieter
You don't HAVE to use polynomial interpolation, do you?
Joe Philllips
I'll have to digest some of this and try some of the suggestions out....I'll get back to you guys soon. I don't think I need polynomial interpolation, but it may work.
Senica Gonzalez
A: 

This is somewhat similar to simple compression schemes used for analogue audio. See Wikipedia entry for Companding.

Paul R
+1  A: 

A suitable logarithmic scale might help.

ssegvic
+1  A: 

It may be possible to define the function you want exactly if you specify a third transformation in addition to the two you've already mentioned. If you have some specific aim in mind, it's quite likely to fit a well-known mathematical definition which at least one poster could identify for you. It does sound as though you're talking about a logarithmic function. You'll have to be more specific about your requirements to define a useful algorithm however.

Tom W
+2  A: 

Something like f(x) = x / log x?

x         | f(x)
=======================
26000     | 5889 (22.6 %)
5000      | 1351 (27.2 %)
100000    | 20000 (20 %)
1000000   | 166666 (16.6 %)

Just a simple example. You can tweak it by playing with the base of the logarithm, by adding multiplicative constants on the numerator (x) or denominator (log x), by using square roots, squaring (or taking the root of) log x or x etc.

Here's what f(x) = 2*log(x)^2*sqrt(x) gives:

x         | f(x)
=======================
26000     | 6285 (24 %)
5000      | 1934 (38 %)
500       | 325 (65 %)
100       | 80 (80 %)
1000000   | 72000 (7.2 %)
100000    | 15811 (15 %)
IVlad
I think this might work great....I'm going to play around a little with it.
Senica Gonzalez
Perfect! Thank you for the layout!
Senica Gonzalez
+1  A: 

I'd suggest you play with the power law family of functions, c*x^a == c * pow(x,a) where a is the power. If you want an exact fraction of your answer, you would choose a=1 and it would just be a constant fraction. But you want the percentage to slowly decrease, so you could choose a<1. For example, we might choose a = 0.9 and c = 0.2 and get

   1   0.2
  10     1.59
 100     12.6
1000     100.2

So it ranges from 20% at 1 to 10% at 1000. You can pick smaller a to make the fraction decrease more rapidly. (And you can scale everything to fit your range.)

In particular, if c*5000^a = 2500 and c*26000^a = 6500, then by dividing we get (5.1)^a = 2.6 which we can solve as a = log(2.6)/log(5.1) = 0.58648.... Then we plug back in to get c*147.69 = 2500 so c = 16.927...

Now the progression goes like so

 1000   973
 3000  1853
 5000  2500
10000  3754
15000  4762
26000  6574
50000  9648
90000 13618
Rex Kerr