Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8143905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:14:05+00:00 2026-06-06T13:14:05+00:00

I need to normalize a vector of N integers so that: Each value is

  • 0

I need to normalize a vector of N integers so that:

  • Each value is proportional to its original value (the value will be between 0 and 1)
  • The sum of all values is =1

For instance:

If I have a vector

V = [2,2,1,0]

the normalized vector should should be:

V_norm = [0.4,0.4,0.2,0]  % 0.4+0.4+0.2 = 1

I tried with many solutions found in this community and on the web and finally I did it with this code:

part = norm(V);
if part > 0
  V_norm = V/part;
else % part = 0 --> avoid "divide by 0" 
  V_norm = part;
end

The problem this works if:

  • all elements of array are “0” –> resultant array doesn’t change
  • only one element of the array is >0 and all other elements are = 0 –> resultant array: the element >0 is 1 and the other 0

but if I have a different case,although the result is proportional,the sum is not 0.
For instance:

   V = [1,0,1]
   V_norm = [0.74,0,0.74]

   V = [1,1,1]
   V_norm = [0.54,0.54,0.54]

(I’m not sure if the number are correct because I can’t use Matlab right now but I’m sure the sum is > 1 )

Ahy hint?

Thank you in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:14:06+00:00Added an answer on June 6, 2026 at 1:14 pm

    … the normalized vector should should be:

    v_norm = [0.4, 0.4, 0.2, 0]; % 0.4+0.4+0.2 = 1

    That depends. What is your norm function?

    norm(x) in MATLAB returns the standard norm, meaning the sum of the squares of the elements of a normalized vector x is 1.

    In your example:

    v = [1, 1, 1];         %# norm(v) = sqrt(1^2+1^2+1^2) = ~1.7321
    v_norm = v / norm(v);  %# v_norm = [0.5574, 0.5574, 0.5574]
    

    sum(v_norm .^ 2) indeed yields 1, but sum(v_norm) does not, as expected.

    I need to normalize a vector of N integers so that each value is proportional to its original value (the value will be between 0 and 1) and the sum of all values is 1.

    What do you mean by "normalize"? Does that mean dividing by a value which is a valid mathematical norm function, according to the norm definition?

    What do you mean by "proportional"? Does that imply that all elements are multiplied by that same number? If it does, and it’s a valid mathematical norm, you cannot guarantee that the sum of the elements will always be 1.
    For instance, consider v = [1, -2]. Then sum(v) = -1.

    Or maybe sum is the function you’re looking for, but it doesn’t mathematically qualify as a norm, because a norm is a function that assigns a strictly positive length or size to all vectors in a vector space.
    In the example above, sum(v) is negative.

    Ahy hint?

    You can choose either:

    1. sum(x), which fulfills both requirements but doesn’t qualify as a norm function since it can yield negative values.
    2. norm(x, 1), as OleThomsenBuus suggested, which actually calculates sum(abs(x(:))).
      It won’t fulfill both your requirements unless you restrict your vector space to non-negative vectors.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do you normalize a M*N vector, such that the sum of all its
I have a table that I need to normalize with many fields In SQL-Server
Is there a standard function to sum all values in a Haskell map. My
I need to write a procedure to normalize a record that have multiple tokens
need a quick help here. I have a series of hyperlinks all with the
I am trying to determine document similarity between a single document and each of
https://i.stack.imgur.com/ARbfh.jpg So I've got a large flat file database which I need to normalize.
I need help with a simple spotlight shader. All vertices inside the cone should
I need to know the average volume of an mp3 file so that when
I have a table with some duplicate rows that I want to normalize into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.