0

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?

8
  • 3
    It sounds like what you need is a "function." Commented May 28, 2010 at 16:37
  • 3
    Sounds like a logarithm or square root to me. Commented May 28, 2010 at 16:38
  • 2
    It is hard to know what to suggest without knowing why you want this. Commented May 28, 2010 at 16:44
  • 1
    You can get something in the rough ballpark of the two examples you give using x->20*sqrt(x). But two examples isn't really enough to specify anything, especially if you want a "sine wave sort of thing". Commented May 28, 2010 at 16:45
  • 1
    Btw, the sine wave is not what you seem to be asking for: doctronics.co.uk/images/sig_02.gif Commented May 28, 2010 at 18:13

6 Answers 6

3

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

Sign up to request clarification or add additional context in comments.

3 Comments

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 :).
You don't HAVE to use polynomial interpolation, do you?
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.
2

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 %)

Comments

1

A suitable logarithmic scale might help.

Comments

1

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.

Comments

1

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

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.