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
0
votes
2 answers

How to find the average of multiple columns with different specific weights?

I need to calculate the average of Value_A, Value_B, and Value_C in mssql. My problem is that every information I need is in one row. Every value has its own weight: (sum of values * weight) / (sum weight): Every column can be null. If there is a…
mrz121
  • 1
0
votes
1 answer

Resample a Pandas dataframe with coefficients

I have a data frame with the following columns: {'day','measurement'} And there might be several measurements in a day (or no measurements at all) For example: day | measurement 1 | 20.1 1 | 20.9 3 | 19.2 4 …
Uri Goren
  • 13,386
  • 6
  • 58
  • 110
0
votes
2 answers

Calculate momentum as weighted average by recency

I have a subscriptions table with an associated feed_id and creation timestamp. A feed has N subscriptions. It's easy enough to show the most popular feeds using a group query to count the number of records with each feed_id. But I want to calculate…
mahemoff
  • 44,526
  • 36
  • 160
  • 222
0
votes
1 answer

average weights in aggregated population

I have a probably very simple question, I hope you will be able to help me with. I have to compute weighted averages for proportion liberal in each american state. I have computed the 'raw' proportion liberal by this…
0
votes
1 answer

Stata: estimating monthly weighted mean for portfolio

I have been struggling to write optimal code to estimate monthly, weighted mean for portfolio returns. I have following variables: firm stock returns (ret) month1, year1 and date portfolio (port1): this defines portfolio of the firm stock…
vikram
  • 17
  • 1
  • 6
0
votes
1 answer

How do I multiply columns of a 2D array? Java

Previous methods construct and fill a 2D double array with a size defined by user input. computeCategoryAverages takes the middle indexes, averages them, then puts them in the final index computeOverallAverage is then supposed to multiply the 0…
Evan
  • 334
  • 1
  • 6
  • 18
0
votes
0 answers

aggregate() with weighted mean in R

I have a dataset like this: data.frame(car brand, car model, car sold, co2 emission) And I want to get the total nb sold per car brand. So I did this: x <- aggregate(carsold ~ carbrand, data=data.frame, FUN=sum) Then, I want to get the average co2…
Synleb
  • 143
  • 2
  • 2
  • 13
0
votes
1 answer

How to calculate time-weighted average and create lags

I have searched the forum, but found nothing that could answer or provide hint on how to do what I wish to on the forum. I have yearly measurement of exposure data from which I wish to calculate individual level annual average based on entry of…
Meso
  • 1,375
  • 5
  • 17
  • 36
0
votes
1 answer

Weighted arithmetic mean of subarray values using php

I have following array: $array = array( array("A",105), array("B",125), array("C",325), array("D",435), array("A",110), array("A",115), array("C",400), …
0
votes
1 answer

Computing weights for multi-site RCT

Assume a multisite RCT with two groups — experimental and control. Weights need to be computed for each time period and site. I am fixing the weights for experimental subjects to 1, and then computing weights for the control subject so the sum of…
Brian P
  • 1,496
  • 4
  • 25
  • 38
0
votes
4 answers

Weight any set of numbers to sum to zero in R

I want to write a function in R that calculates weights to sum any set of numbers in R to zero. For example if x <- c(-5, 6, 2, 4, -3) I want a function that would return a new vector which has been weighted to force the vector sum to zero, by…
user3343467
  • 185
  • 1
  • 2
  • 9
0
votes
1 answer

Weighted mean(sd) without single values

I have two samples, for which I have means(sd) and sizes. i.e. 6.27 +/- 5.9 (size 34) 5.91 +/- 4.9 (size 6) How can I concatenate the two samples and have a mean and a SD? TY in advance.
lorenzo.g
  • 23
  • 3
0
votes
2 answers

How to get conditional weighted means for several columns

For the following dataframe: eu <- structure(list(land = structure(c(1L, 4L, 5L, 12L, 9L, 13L, 16L, 18L, 27L, 10L, 25L, 21L, 28L, 19L, 8L, 26L, 6L, 3L, 15L, 14L, 11L, 17L, 20L, 23L, 24L, 2L, 22L, 7L), .Label = c("Belgie", "Bulgarije", "Cyprus",…
Jaap
  • 81,064
  • 34
  • 182
  • 193
0
votes
1 answer

Python Hopfield Network: Training network - error with weights

I'm new to programming and am currently having some simple issues trying to train my hopfield network but I keep getting this error when trying to calculate the weight of the connections. Perhaps I am not understanding how to "train" the network or…
0
votes
2 answers

compute time series weighted average

I have a 8760x1 vector with the 1-hour average ambient temperature time series. I want to calculate the weighted average temperature weighted by the percentage of operating hours at each temperature level. What i thought is divide the temperature…
user3172906
  • 5
  • 1
  • 4