User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion

Reply
Thread Tools Display Modes
Unread 14 Aug 2006, 14:02   #1
Dante Hicks
Clerk
 
Join Date: Jun 2001
Posts: 13,940
Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.
Really Basic Maths

This is really shameful, but I can't think of any way of doing this. I seem to remember doing it in GCSE Maths when plotting graphs, but there's little chance of remembering that.

I have a series of items, all of which have a score against them. The score's range from 0.81487916 (lowest score) to 1.248544456 (highest score). However, I need to represent these as scores of -4 up to 5. So 0.81 would be -4 and 1.245 would be 5. But how do I convert the values to the other form? If another item has a score of 1.1, what would that be?

(Obviously I can just a series of IF statements to sort them into bands since I presume each increment along will be (1.2845-0.81) / 10 big , but I'm presuming there is a way of doing this via arithmetic)
Dante Hicks is offline   Reply With Quote
Unread 15 Aug 2006, 13:36   #2
meglamaniac
Born Sinful
 
meglamaniac's Avatar
 
Join Date: Nov 2000
Location: Loughborough, UK
Posts: 4,059
meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.
Re: Really Basic Maths

Ok, I've worked this out from scratch (couldn't remember enough about how to do it) so it could be wrong. But I don't think it is. In GCSE terminology what you're trying to do is a "slide" operation (move numbers to a different section of the number line) and a "scale" operation (adjust the range of a group of numbers on the number line). I'm not sure what the real term is but it probably classes as normalisation.

Anyway:

Find the range

range = 0.433665296 (1.248544456 - 0.81487916)

range needs to = 9 (5 - -4)


Find the scale factor

9 / 0.433665296 = 20.753332311838944105870994113396


proof:

oldRange * SF = newRange

0.433665296 * 20.753332311838944105870994113396 = 9

Let's call the scale factor x


Testing the scale factor

0.81487916 * x = 16.911458001472176828279106751489

1.248544456 * x = 25.911458001472176828279106751489

25.911458001472176828279106751489 - 16.911458001472176828279106751489 = 9.0000000000000000000000000000088

Near enough. Error is due to internal floating point rounding (I've been using Windows Calculator. It's not the best.)


Finally

Let's get our "slide" factor, y.
y = lowest scaled value + 4
y = 16.911458001472176828279106751489 + 4 = 20.91145800147217682827910675148


m = (n * x) - y

where
n is the input unnormalised value and
m is the output normalised value




Also I just realised that form looks familiar.

y = mx + c

The parametric straight line formula.
Which, of course, makes sense. Yes I know it's a minus not a positive in the one we ended up with, but that could just as easily be the case with this formula if c was a negative value. If that doesn't make sense to you, imagine our forumula as m = nx + y instead, then make the value of our slide factor, y, negative. It would produce exactly the same results.

Reassigned values for the straight line forumula:
y is the normalised output.
x is the original input.
m, the gradient, is the scale factor.
c, the constant, is the slide factor (y in the formula we ended up with above).

Plug your numbers into this and you can get a pretty graph of where any scaled number will end up.
__________________
Worth dying for. Worth killing for. Worth going to hell for. Amen.

Last edited by meglamaniac; 15 Aug 2006 at 13:47.
meglamaniac is offline   Reply With Quote
Unread 16 Aug 2006, 11:40   #3
Saphi
Leo's Pwn :P
 
Join Date: Jun 2006
Location: just outside of Newton Abbot, Devon, UK
Posts: 118
Saphi is infamous around these partsSaphi is infamous around these partsSaphi is infamous around these partsSaphi is infamous around these partsSaphi is infamous around these partsSaphi is infamous around these partsSaphi is infamous around these partsSaphi is infamous around these parts
Re: Really Basic Maths

me bivvers at the thought of this ...floods back uni and a-level maths

/me shudders

gd though megla
__________________
neg rep me if u must but remember red is my favourite colour in pa
------------------------------------------------
[TDM] an mmo alliance coming to an mmo near you soon
------------------------------------------------
The answers you seek are not here
Saphi is offline   Reply With Quote
Unread 16 Aug 2006, 11:52   #4
Dante Hicks
Clerk
 
Join Date: Jun 2001
Posts: 13,940
Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.Dante Hicks has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.
Re: Really Basic Maths

Thanks Megla, this worked perfectly. Much love to you!
Dante Hicks is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Forum Jump


All times are GMT +1. The time now is 20:00.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018