"Normalize" values to sum 1 but keeping their weights I am not really sure what this operation might be called, but I have some numbers, for example:

*

*40

*10

I need to format these numbers so that they form the sum 1, but they should keep their "weight".
In this specific case:

*

*40 would become 0.80

*10 would become 0.2

But if I have more values (like 40, 10, 25, 5 for example), I am really lost because I don't know the formula.
If anybody can help, could they please reply in words (for example: "Sum up all values then divide through...", and not in a formula? I am really not good at reading formulas at all.
 A: Why not just divide each number in your sample by the sum of all the numbers in your sample?
A: The answers provided here won't work in cases where the set contains negative numbers.
The function you're looking for is called the softmax function. The softmax function is often used in the final layer of a neural network-based classifier. 
Softmax is defined as:
$$f_i(x) = \frac{e^{x_i}}{\sum_j e^{x_j}}$$
A: I'm currently learning probability from an online course. 
It's teaching me to use this amazingly simple method, and so far it has worked flawlessly!
Where e is an element in the list of numbers to be normalized:
Calculate a normalizer (multiplier) like so:
normalizer = 1 / (e1 + e2 + e3)

Next, multiply the normalizer to every element in the list:
((e1 * normalizer) + (e2 * normalizer) + .... + (en * normalizer) ) == 1.0

... and they will add up to 1.0.
So taking your example of numbers 10 and 40:
normalizer = 1 / (10 + 40) = 0.02
(10 * 0.02) = 0.2
(40 * 0.02) = 0.8
(0.2 + 0.8) = 1.0

Hence we get our 1.0.
I've gone ahead and written a simple Python script that you can run on almost any Python interpreter and play around with the parameters and test the results.
# python script
import random as rnd

# number of items in list, change this to as huge a list as you want
itemsInList = 5 

# specify min and max value bounds for randomly generated values
# change these to play around with different value ranges
minVal = 8
maxVal = 20

# creates a list of random values between minVal and maxVal, and sort them
numList = sorted( [rnd.randint(minVal, maxVal) for x in range(itemsInList)] )
print ('initial list is\n{}\n'.format(numList))

# calculate the normalizer, using: (1 / (sum_of_all_items_in_list))
normalizer = 1 / float( sum(numList) )

# multiply each item by the normalizer
numListNormalized = [x * normalizer for x in numList]
print('Normalized list is\n{}\n'.format(numListNormalized))

print('Sum of all items in numListNormalized is {}'.format(sum(numListNormalized)))

Running the code gives this sample output:
initial list is
[9, 12, 15, 16, 19]

Normalized list is
[0.1267605633802817, 0.16901408450704225, 0.2112676056338028, 0.22535211267605634, 0.26760563380281693]

Sum of all items in numListNormalized is 1.0

I hope this helps!
A: From the text description, it seems this is what you want:


*

*calculate the sum of all elements

*divide each element by the sum


Note that, however, then your example $[40, 10]$ normalises as $[0.8, 0.2]$, not $[0.75,0.25]$. The latter doesn't preserve the ratio of both elements.
A: My take on the problem. First, in order to get rid of negative numbers, subtract all values in the original vector $\vec{x}$ by the minimum value in it: $\vec{u}=\vec{x}-\text{min}(\vec{x})$. This will ensure the minimum value in $\vec{u}$ will be 0. Then, the final "normalized" values between 0 and 1 are given by $$z_i = \frac{\vec{u}_i}{\sum_{j \in \vec{u}} \vec{u}_{j}}.$$
Edit: as pointed out in the comments, subtracting the minimum value of $\vec{x}$ from all values in $\vec{x}$ should only be done if at least one of the values in $\vec{x}$ is negative. After this step, the sum of the values in the final vector $\vec{z}$ will be 1.
What it means to calculate ratios involving negative values is open to interpretation. Maybe it's a closer behavior to that of the softmax function in machine learning, as it makes all values positive and sum to 1.
A: Divide $100$ by the sum which is $80$ to get $1.25$. Then you multiply the the terms and use simple proportion where $80*1.25=100$ is proportional to one. You will get answers like $05,0.125,0.3125$ and $0.0625$.  
A: Just divide all the numbers through by 50. Should normalise it to the scale you want 0 - 1.
For example:
40/50 = 0.8
25/50 = 0.5
5/50 = 0.1
etc.
I think you get the idea!
