vb.netnormalizationdenormalizationdenormalized

DeNormalizing Value Based on Data Set VB.NET


Say I used the following to normalize my data set to [1, -1]:

Public Function NormalizeData(values As Double()) As Double()
    Dim min = values.Min
    Dim max = values.Max
    Return values.Select(Function(val) 2 * (val - min) / (max - min) - 1).ToArray
End Function

How would I go about de-normalizing a value based on that data set:

Public Function DeNormalizeData(baseData As Double(), value As Double) As Double
        Dim min = baseData.Min
        Dim max = baseData.Max
        Return '??
End Function

Solution

  • Find the inverse of your function: dn=denormalized, n=normalized

    n= 2*((dn-min)/(max-min)) - 1 adding 1 to both sides

    n+1=2*((dn-min)/(max-min)) divide by 2

    (n+1)/2=(dn-min)/(max-min) multiply by (max-min)

    ((max-min)*(n+1))/2 = dn - min add min to both

    dn =(((max-min)*(n+1))/2)+min

    You now have the function for de-normalizing, as you can see you need to save the max and min values.

    public function DeNormalize(n as double, min as double, max as double) as double 
        return (((max-min)*(n+1))/2)+min
    end function