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

python: filter with weighted footprint

I would like to use a "footprint filter with weights" in Python. I tried to use the generic_filter from scipy.ndimages.filters. But it does not take weights. A little bit more details: I do have meteorological data and I would like to create…
0
votes
1 answer

Aggregate to find the weighted median

I have the following data set: df <- data.frame( C = c(1,2,3,1,2,3,1,2,3,1), weight = c(1,1.5,2,2,1.5,1,2,1,1.5,2.5), time = c(15,20,30,45,60,15,20,30,45,60) ) I need to aggregate the data by the variable C in order to find the median…
user2568648
  • 3,001
  • 8
  • 35
  • 52
0
votes
1 answer

Average calculation procedure

i'm implementing a mysql database for saving logged energy consumption data out of a smart home applications. The data then should be plotted within a javascript framework. Unfortunately the usage get's logged every 8 seconds and there's too much…
user3137588
0
votes
1 answer

Optimizing weights for average across 3 variables

I am trying to create an ensemble of machine learning and I have code that made predictions based on occupation Ocp, Age Age, and Gender Gender. I want to average the 3 predictions for a final prediction, but I am not sure how I should optimize the…
user2492310
  • 89
  • 1
  • 8
0
votes
1 answer

need help finding the weighted average

getting the error in my code Traceback (most recent call last): File "C:/Users/Daniel Nase/Desktop/assignment 7 test.py", line 119, in main() File "C:/Users/Daniel Nase/Desktop/assignment 7 test.py", line 23, in main …
0
votes
2 answers

Trying to calculate weighted moving average but getting zero as result always

I am trying to get out the "Weighted moving average" of a array of double values. I have tried to get all peaces from some internet examples together but i always getting zero as result. Problem is the calulation of "weight", its being zero but it…
RickardP
  • 2,558
  • 7
  • 34
  • 42
0
votes
1 answer

What is the weight function in weka IBk?

I'm performing kNN prediction of numerical variable (knn regression or Locally weighted average). I am using euclidean distance and 1/distance as weights but I don't know how this is applied. and I have question: How exactly the weightning in WEKA…
alchemist_bg
  • 148
  • 2
  • 8
0
votes
1 answer

Weighted score of a multiple-choice option with more than one answer

What would be the formula to calculate the weighted score for the following scenario? Some question is asked with answer scores ranging from 0 to 5. No correct or incorrect classification. Just a relative score range. Answer 1 Weight = 5 Answer 2…
0
votes
2 answers

Optimal algorithm for 5-point weighted average in C

I want to find the "true" peak position in an array of numbers. After finding the index of the largest value I apply the weighted average to determine the true peak position. This requires two indexes to the left and two to the right. But what if…
Davorin
  • 1,160
  • 15
  • 31
0
votes
1 answer

time-weighted average in xts or zoo

How to calculate the time-weighted average of an xts object for e.g 5 minutes: I know weighted.mean() but don't know how to deal with the date and time. Thanks library(xts) structure(c(28.2, 28.2, 28.2, 28.2, 28.1, 28.1, 28.1, 28.1, 28.1,…
Herr Student
  • 853
  • 14
  • 26
0
votes
1 answer

Calculation weigths in combine classifier outputs

I have 3-class classification problem and I have ensemble with 4 classifiers. Each classifier returns supports for each class. Now I want to combine this outputs using weighted average with c*L weights (c=3, L=4), but I don't know how can I…
veeveeoor
  • 205
  • 1
  • 2
  • 11
0
votes
1 answer

Weighting output of cost function based on user input

Hi I am creating an android app that will generate a cycling route for users using a route finder. I am trying to allow the user to either prefer distance or routes with cyclelanes present. I have a slider from 0 to 10, where 0 means the user wants…
sam
  • 2,469
  • 8
  • 37
  • 57
0
votes
1 answer

Approximate factors in an average calculation

here is what I want to do: I have an double[] of size N (N will not be larger than 500 but different applications of this program will have different Ns). I now want to find out what combinations I can achieve a given average with. For example: The…
Killerpixler
  • 4,200
  • 11
  • 42
  • 82
0
votes
1 answer

calculate mean and variance for weighted discrete random variables in R

I have the following data frame: dat <- read.table(text=" X prob 1 1 0.1 2 2 0.2 3 3 0.4 4 4 0.3", header=TRUE) Is there any built-in function or elegant way to calulate mean and variance for discrete random variables in R?
Qiang Li
  • 10,593
  • 21
  • 77
  • 148
0
votes
1 answer

SQL Server AVG function oddity

I am seeing some odd behavior in SQL Server AVG calcuation. On manual calculation, you get 49.277588 but SQL Server is reporting that the average is 50.9914 as shown below. Question: Can someone explain the difference and why this is…
dance2die
  • 35,807
  • 39
  • 131
  • 194