Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"uninormalize" function #160

Open
abbradar opened this issue May 13, 2016 · 1 comment
Open

"uninormalize" function #160

abbradar opened this issue May 13, 2016 · 1 comment

Comments

@abbradar
Copy link

abbradar commented May 13, 2016

Hi,

A small addition: would you be interested in adding a function for a vector normalization in [0;1] range? I haven't found a function for this, and it seems a good fit here; I imagine people reimplement it again and again. It's essentialy:

function uninormalize(v)
    min = minimum(v)
    max = maximum(v)
    if (min == max)
        fill!(copy(v), 0)
    else
        (v - min) / (max - min)
    end
end

If it's OK I can provide a PR.

@ararslan
Copy link
Member

Hello! This seems like an okay idea to me. What's your reasoning for the name uninormalize? Is it a common convention to normalize to 0 if the input has only one unique value?

You can use extrema and tuple assignment to get the min and max at the same time, and zeros(v) in place of fill!(copy(v), 0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants