Questions tagged [weighted-average]

The weighted average or weighted mean is similar to an arithmetic mean where instead of each of the data points contributing equally to the final average, some data points contribute more than others.

If all the weights are equal, then the weighted mean is the same as the arithmetic mean.

The mathematical expression for the weighted average is

enter image description here

Read more here

476 questions
-1
votes
1 answer

Matlab 3x3 weighted averaging filter

Following advise from another post, I created a basic 3x3 averaging filter as follows: blurP = zeros(512, 512); for i = 1:510 for j = 1:510 sum = 0; for k = i:i+2 for l = j:j+2 sum = sum+P(k,l); end end …
sebastianross
  • 33
  • 1
  • 7
-1
votes
1 answer

Correct way to get weighted average of concrete array-values along continous interval

I've been looking for a while onto websearch, however, possibly or probably I am missing the right terminology. I have arbitrary sized arrays of scalars ... array = [n_0, n_1, n_2, ..., n_m] I also have a function f->x->y, with 0<=x<=1, and y an…
Sebastian Mach
  • 38,570
  • 8
  • 95
  • 130
-2
votes
1 answer

SUMIFS in Power BI

I need to create 2 SUMIFS columns in Power Bi with multiple criteria. One column will be "Per Charge Per month" to find the total charges with "Sum of Charge Amount", "charge bucket", "Type", and "Delivery Month Column" columns as criteria. The…
Spen820
  • 3
  • 1
  • 3
-2
votes
2 answers

nanmean with weights to calculate weighted average in pandas .agg

I'm using a lambda function in a pandas aggregation to calculate the weighted average. My issue is that if one of the values is nan, the whole result is nan of that group. How can I avoid this? df = pd.DataFrame(np.random.randn(5, 3), index=['a',…
Nickpick
  • 6,163
  • 16
  • 65
  • 116
-2
votes
1 answer

compute absolute distance/weighted moving average. Stata or R

I want to capture in a variable (called “absolutedistance”) the absolute value of the distance of a numeric variable (called “v1”) between a given subject (identified with var “id”; total 50 subjects) in a given year (identified with var “duration”;…
vic_tor
  • 1
  • 3
-2
votes
3 answers

Weighted average of pair elements in a vector in R

I have two vectors x and w. vector w is a numerical vector of weights the same length as x. How can we get the weighted average of the fisrt pair elements in vector x which their difference are small (for example tol= 1e-2) and then in the next…
Bensor Beny
  • 285
  • 2
  • 13
-3
votes
1 answer

Compute weighted average for selected rows in SQL

My data set has a weight column and a variable of interest var1, for which I need to form a weighted average of all rows that satisfy either var1=1 and var1=2. Unfortunately I need to do this in SQL, where I have very limited knowledge. To compute…
user239092
  • 29
  • 2
-3
votes
2 answers

Stata - Generating rolling average variable

I'd like to generate a rolling average variable from a basketball dataset. So if the first observation is 25 points on January 1, the generated variable will show 25. If the second observation is 30 points on January 2, the variable generated will…
user3654703
  • 1
  • 1
  • 3
-3
votes
3 answers

Weighted Mean by Date

I have the following dataframe: df = data.frame(date = c("26/06/2013", "26/06/2013", "26/06/2013", "27/06/2013", "27/06/2013", "27/06/2013", "28/06/2013", "28/06/2013", "28/06/2013"), return = c(".51", ".32", ".34", ".39", "1.1", "3.2", "2.1",…
rwn1v
  • 777
  • 3
  • 10
  • 23
-4
votes
2 answers

How to calculate a decaying average?

I have an array of samples, suppose its length is 10. Now I want to weight them, so that I can get an average where the oldest samples take a little bit more weight than the fresh ones. For example, Position 1 = 100%, Position 10 = 10% weighing. How…
Maestro
  • 9,046
  • 15
  • 83
  • 116
-4
votes
1 answer

How to compute the average of correlated values?

Let us assume the following vector: x = c( 0.5, 0.4, 0.8 ) where the x[1] and x[2] values are correlated, with the correlation matrix: x[1] x[2] x[3] x[1] 1 0.8 0 x[2] 0.8 1 0 x[3] 0 0 1 I want to compute the average…
Xavier Prudent
  • 1,570
  • 3
  • 25
  • 54
1 2 3
31
32