Selective Normalization

We want to normalize a list of measures selectively, meaning that the normalization is done upon some measures (those indicated by the boolean values in an auxiliar list) only. You are required to deliver the following function in the module selnorm (file selnorm.py):

selnorm(sL, mL)

such that

given

updates mL such that:

  • the positions where sL have the False value, get a 0.0

  • the positions where sL have the True value are normalized (ie. they are all proportionally updated in order to sum 1.0). The normalized value must be rounded to 2 decimals.

For example:

>>> sL = [False, True, False, True, True, False]
>>> mL = [5.0, 10.0, 3.75, 6.0, 4.0, 8.8]
>>> selnorm(sL, mL)
>>> mL
[0.0, 0.5, 0.0, 0.3, 0.2, 0.0]

Doctests are available in the selnorm.test file.