Because all of the errors have the same relative weight. Supplying a weight parameter does not change the actual values you are averaging, it just indicates the weight with which each value value contributes to the average. In other words, after multiplying each value passed by its corresponding weight, np.average divides by the sum of the weights provided.

>>> import numpy as np
>>> np.average([1, 2, 3], weights=[0.2, 0.2, 0.2])
2.0
>>> np.average([1, 2, 3])
2.0

Effectively, the average formula for an n-dimensional array-like container is

                               

where each weight is assumed to be equal to 1 when not provided to numpy.average.

Answer from miradulo on Stack Overflow
🌐
NumPy
numpy.org › doc › 2.5 › reference › generated › numpy.average.html
numpy.average — NumPy v2.5 Manual
An array of weights associated with the values in a. Each value in a contributes to the average according to its associated weight. The array of weights must be the same shape as a if no axis is specified, otherwise the weights must have dimensions and shape consistent with a along the specified ...
🌐
Programiz
programiz.com › python-programming › numpy › methods › average
NumPy average()
The numpy.average() method returns the weighted average of the array.
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.mean.html
numpy.mean — NumPy v2.2 Manual
Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. float64 intermediate and return values are used for integer inputs.
🌐
DataCamp
datacamp.com › doc › numpy › mean
NumPy mean()
NumPy's `mean()` function is a fundamental tool in array computation and analysis, used to calculate the arithmetic average of elements within an array.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-is-np-mean-different-from-np-average-in-numpy
How is np.mean() different from np.average() in NumPy? - GeeksforGeeks
July 23, 2025 - In the Numpy library, there are two functions np.mean() and np.average() are present. Both are actually doing nearly the same job of calculating mean/average. The difference comes when we are calculating the weighted average.
🌐
Codecademy
codecademy.com › learn › ida-3-introduction-to-numpy › modules › ida-3-2-numpy-syntax › cheatsheet
NumPy: A Python Library for Statistics: Statistics in NumPy Cheatsheet | Codecademy
In a two-dimensional array, you may want the mean of just the rows or just the columns. In Python, the NumPy .mean() function can be used to find these values. To find the average of all rows, set the axis parameter to 1.
Top answer
1 of 3
43

Because all of the errors have the same relative weight. Supplying a weight parameter does not change the actual values you are averaging, it just indicates the weight with which each value value contributes to the average. In other words, after multiplying each value passed by its corresponding weight, np.average divides by the sum of the weights provided.

>>> import numpy as np
>>> np.average([1, 2, 3], weights=[0.2, 0.2, 0.2])
2.0
>>> np.average([1, 2, 3])
2.0

Effectively, the average formula for an n-dimensional array-like container is

                               

where each weight is assumed to be equal to 1 when not provided to numpy.average.

2 of 3
4

My answer is late, but I hope this will be of use to others looking at this post in the future.

The above answers are spot on with respect to why the results are the same. However, there is a fundamental flaw in how you are calculating your weighted average. The uncertainties in your data ARE NOT the weights that numpy.average expects. You have to calculate your weights first and provide them to numpy.average. This can be done as:

weight = 1/(uncertainty)^2.

(see, for example, this description.)

Therefore, you would calculate your weighted average as:

wts_2e13 = 1./(np.power(bias_error_2e13, 2.)) # Calculate weights using errors

wts_half = 1./(np.power(error_half, 2.)) # Calculate weights using half errors

test = np.average(bias_2e13, weights = wts_2e13)

test_2 = np.average(bias_2e13, weights = wts_half)

giving you the answers of 2.2201767077906709 in both cases for reasons explained well in the above answers.

🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.ma.average.html
numpy.ma.average — NumPy v2.6.dev0 Manual
Axis or axes along which to average a. The default, axis=None, will average over all of the elements of the input array.
Find elsewhere
🌐
Medium
medium.com › @amit25173 › what-is-a-numpy-moving-average-and-why-use-it-in-numpy-79cfadfaa49f
What is a Moving Average and Why Use It in NumPy? | by Amit Yadav | Medium
February 8, 2025 - Before diving into calculations, you’ll need to set up your environment. Start by importing NumPy and creating a dataset. Here’s how you do it: import numpy as np # Example dataset data = [10, 20, 30, 40, 50, 60] This dataset represents values you might want to smooth, like daily temperatures or sales numbers. Step 2: Using NumPy’s convolve() Method for Moving Average
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.mean.html
numpy.mean — NumPy v2.6.dev0 Manual
Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. float64 intermediate and return values are used for integer inputs.
🌐
NumPy
numpy.org › doc › 2.3 › reference › generated › numpy.average.html
numpy.average — NumPy v2.3 Manual
An array of weights associated with the values in a. Each value in a contributes to the average according to its associated weight. The array of weights must be the same shape as a if no axis is specified, otherwise the weights must have dimensions and shape consistent with a along the specified ...
🌐
Medium
medium.com › @whyamit101 › understanding-weighted-average-with-numpy-cfb245fced2a
Understanding Weighted Average with NumPy | by why amit | Medium
February 9, 2025 - Let’s address a couple of scenarios you might encounter. What happens if weights are not provided? If you don’t specify weights, numpy.average() defaults to a regular average, treating all values equally.
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: Sum, mean, max, min for entire array, column/row-wise | note.nkmk.me
January 20, 2024 - NumPy allows you to calculate the sum, average, maximum, and minimum of an array (ndarray) using functions such as np.sum(), np.mean(), np.max(), and np.min(). These functions allow you to specify the ...
🌐
Codecademy
codecademy.com › docs › python:numpy › math methods › .average()
Python:NumPy | Math Methods | .average() | Codecademy
June 20, 2025 - In NumPy, the .average() method is used to compute the weighted average of array elements along specified axes.
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-mean-in-python
numpy.mean() in Python - GeeksforGeeks
June 26, 2026 - numpy.mean() is used to calculate the arithmetic mean (average) of numeric data. It can find the mean of all elements in an array or calculate means along specific rows or columns of a multi-dimensional array.
🌐
Vultr Docs
docs.vultr.com › python › third party › numpy › average()
Python Numpy average() - Compute Mean Value
November 11, 2024 - Compute the weighted average using the average() function. ... import numpy as np data = np.array([10, 20, 30, 40, 50]) weights = np.array([1, 2, 3, 4, 5]) weighted_mean = np.average(data, weights=weights) print(weighted_mean)
🌐
ProjectPro
projectpro.io › recipes › compute-averages-sliding-window-over-array
How to use NumPy for Moving Average computation | ProjectPro
October 16, 2023 - NumPy, a powerful Python library for numerical computations, offers a versatile set of tools to work with moving averages. In this comprehensive guide, we will explore various aspects of moving averages, covering smooth averages, sliding window calculations, cumulative moving averages, and exponential moving averages using NumPy functions.
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.matrix.mean.html
numpy.matrix.mean — NumPy v2.2 Manual
Returns the average of the matrix elements along the given axis. Refer to numpy.mean for full documentation.