Reputation: 6467
I have the following conversion table:
and I need to convert the values of the second column to the values in the first column, as continuous variables.
Currently, I am trying to write a function that accepts a value from the second column, check its validity and then uses the following conversion formula for the data transformation:
The code currently looks like this:
Public Function ReScale (input As Double)
'Max and Min values of the old scale.
Dim MinOld As Double: MinOld = 2
Dim MaxOld As Double: MaxOld = 6
'Test input value validity.
If input > MaxOld Or input < MinOld Then
ReScale = CVErr(xlErrNA)
End
Dim MinNew As Double
Dim MaxNew As Double
'Find in which interval the input value belongs.
If input >= 5.5 Then
MinOld = 5.5
MaxOld = 6.0
MinNew = 85
MaxNew = 100
ElseIf input >= 4.50 And input <= 5.49 Then
MinOld = 4.50
MaxOld = 5.49
MinNew = 65
MaxNew = 84
...` <--------------------- Question?
'Transform the old data to the new scale.
ReScale = ( (MaxNew - MinNew) / (MaxOld - MinOld) ) * (input - MaxOld) + MaxNew
End Function
My question is:
Should I search for MaxNew
, MinNew
, MaxOld
and MinOld
depending on the variable value or should I use the absolute minimum and maximum?
Is there an easier way of doing this?
Upvotes: 0
Views: 106
Reputation: 7951
This is a bit of a Frame Challenge:
At the moment, this grading system gives a really sharp change in the grading structure at the boundaries. For example, take a look at the following conversions:
A Grading Curve is generally called that for a reason - to give a smooth distribution and transition. If you were to drop a cubic trendline on your graph, you can almost (but not quite) get there with y = 0.0015x^3 - 0.1115x^2 + 4.545x - 5.5277
:
(I have circled the sharp transitions, and the fact that the equation given currently goes negative at x=2
)
Upvotes: 1