Skip to content

MinMaxNormalization Not Resulting in Expected 0-1 Range #12

Open
@rdyan0053

Description

@rdyan0053

I tested MinMaxNormalize with the following code:

from torch_ecg._preprocessors import MinMaxNormalize
minmax = MinMaxNormalize()
sig = raw_sig[:, 0]  # lead1, shape: (5000,)
sig_minmax, fs_minmax = minmax(sig, fs=500)
# plot
plt.figure(figsize=(20, 10))
plt.subplot(211)
plt.plot(sig)
plt.subplot(212)
plt.plot(sig_minmax)
plt.show()

image
To my surprise, the results from MinMaxNormalize weren't as expected within the 0-1 range. Instead, all values turned out to be 0 (In the above figure you can see the second curve). I would like to understand why this happened.

For further verification, I tested using the code below:

sig = raw_sig[:, 0]  # lead1, shape: (5000,)
# use the min-max normalization to normalize the signal to [0, 1]
sig_minmax = (sig - np.min(sig)) / (np.max(sig) - np.min(sig))
# plot
plt.figure(figsize=(20, 10))
plt.subplot(211)
plt.plot(sig)
plt.subplot(212)
plt.plot(sig_minmax)
plt.show()

image
I found that my own code was effective and could correctly normalize the signal values to the [0, 1] range.

I hope to receive your feedback and clarification on this matter. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions