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
1 answer

Applying weights to a Pandas Dataframe to identify recurring terms

I have a very large Pandas Dataframe with a list of terms found in a large library of text. The columns are the term and the amount of times that term appears in the text: Term Hits volvo car handbrake 300 kelly blue book …
GreenGodot
  • 6,030
  • 10
  • 37
  • 66
0
votes
1 answer

Weight Average for every Pandas groupby with uneven rows?

So i wanted to find the weight average of grades with thick as the weight. Problem is, i need to do it everytime the Grade shows >0 consecutively, and if it's 0 consecutively, i would still like to find it's weight average although its 0 for…
Jayakusuma
  • 39
  • 4
0
votes
0 answers

Exponentially weighted running mean (moving average) using Pandas

I have been trying to get the exponentially weighted running mean for a series of mean daily outdoor temperatures (temp_series), defined as follows: I would like to use a value of alpha=0.8 and input a custom period of days. I have tried using: trm…
Andreuccio
  • 1,053
  • 2
  • 18
  • 32
0
votes
1 answer

Calculating weighted average according to various variable classes in R

I have size data of different species. Each sample represents a plot of reef of 1 m^2 (a quadrat; "Unique"). There should be 5 quadrats at each site in any given year ("YrSi") and any number of species at a quadrat (some have more then others and…
opel
  • 73
  • 6
0
votes
1 answer

Calculate weighted average with varying weights and missing values in R

I'm trying to calculate the weighted average of 3 columns where the weights are decided based on the count of missing values per row. A reproducible example: # Some simulated data N <- 50 df <- data.table(int_1 = runif(N,1000,5000), int_2 =…
Debbie
  • 391
  • 2
  • 18
0
votes
1 answer

pandas time-weighted average groupby in panel data

Hi I have a panel data set looks like stock date time spread1 weight spread2 VOD 01-01 9:05 0.01 0.03 ... VOD 01-01 9.12 0.03 0.05 ... VOD 01-01 10.04 0.02 0.30 ... VOD 01-02 …
FlyUFalcon
  • 314
  • 1
  • 4
  • 18
0
votes
1 answer

Calculate weighted means for multiple grouping with different weightings in R

I've gone through the many posts on SO trying to get my code to work but still have some errors. I'm trying to calculate weighted means for many columns based on different groupings. Specifically, I want to calculate the weighted mean of traits…
KNN
  • 459
  • 4
  • 19
0
votes
1 answer

weighted moving average in pandas - having trouble implementing

I have a one-dimensional time series (below), created using pandas. that I'm having trouble creating a weighted moving average for. I've seen others have come across this problem in pandas but there doesn't seem to be a consensus solution from what…
Will
  • 43
  • 1
  • 2
  • 5
0
votes
1 answer

Calculate weighted average in pandas with unique condition

I'm trying to calculate the weighted average of the "prices" column in the following dataframe for each zone, regardless of hour. I want to essentially sum the quantities that match A, divide each individual quantity row by that amount (to get the…
0
votes
1 answer

Pandas calculate and apply weighted rolling average on another column

I am having a hard time figuring out how to get "rolling weights" based off of one of my columns, then factor these weights onto another column. I've tried groupby.rolling.apply (function) on my data but the main problem is just conceptualizing how…
0
votes
1 answer

How to do weighted average of two device_vectors with points selected using map in thrust?

I have two device_vector P & Q (say of size 100). I have two device_vector maps(MapP & MapQ of size say 10) for P & Q which has the indices of points to be selected from P & Q. I have a device_vector D for weight. I need to compute (P*D+Q)/(D+1) for…
user27665
  • 673
  • 7
  • 27
0
votes
1 answer

Find the weights from an existing point to position a point relative to a triangle using weighted average

My understanding is I can position a point anywhere inside a triangle in 3D space using a weighted average: import numpy as np triangle = np.arange(9) triangle.shape = (3,3) weights = np.array([1, 0.3, 20]) point = np.average(triangle,…
Rich Colburn
  • 253
  • 2
  • 7
0
votes
1 answer

Pandas: Calc. weighted-average price, using groupby / lambda or function?

I have DataFrame where 4 unique orders are split into row 3-12. As you can see below in step 1, 2 and 3 I am using groupby to make it so that 1 order = 1 row. I am missing one crucial step however, calculating the weighted average price for each…
snackman003
  • 27
  • 1
  • 6
0
votes
1 answer

DAX suggestions to generate specific weighted average measure in PowerBI?

I'm trying to formulate weighted average measures in PowerBi for survey data. I've currently got the following two tables (simplified): Survey Data ID How would you score the service? Do you agree with…
0
votes
0 answers

quaternion weighted average filter using color images in MATLAB

In here I want to input color image, then extract rgb color spaces and divide these rgb color pixels in to 3-by-3 submatrices, then also I want to calculate pixel distance by using intensity and chromaticity differences simultaneously. Then again I…