Summation of All Numbers¶
- sum_value(data)¶
Calculates the sum of all elements in a data set
- Parameters
data (list of int or float) – List of numbers
- Raises
TypeError – Argument must be a 1-dimensional list
TypeError – Elements of argument must be integers or floats
- Returns
total – Number representing the sum of all elements in the original set
- Return type
float
See also
Notes
Set of numbers: \(a_i = \{ a_1, a_2, \cdots, a_n \}\)
Sum of all numbers in set: \(\sum\limits_{i=1}^n a_i = a_1 + a_2 + \cdots + a_n\)
Examples
- Import sum_value function from regressions library
>>> from regressions.statistics.summation import sum_value
- Find the total sum of all values in the array [2, 3, 5, 7]
>>> total_1 = sum_value([2, 3, 5, 7]) >>> print(total_1) 17.0
- Find the total sum of all values in the array [1, -1, 1, -1]
>>> total_2 = sum_value([1, -1, 1, -1]) >>> print(total_2) 0.0