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

How to find probability of predicted weight of a link in weighted graph

I have an undirected weighted graph. Let's say node A and node B don't have a direct link between them but there are paths connects both nodes through other intermediate nodes. Now I want to predict the possible weight of the direct link between the…
1
vote
1 answer

Implementing a weighted average on the fly in Python

I have a stream of coming data and I want to implement the moving average on the fly. If all the elements in the moving average have the same weight it is fairly easy to implement using a 'Queue' but I want the most recent elements to have higher…
1
vote
1 answer

Weighted Averages Updating Through The Day

I want to calculate the weighted average of a set of data. At the end of each time block a value will be entered. The time blocks are all worth different amounts with Time A being 2.5 hours, Time B is 3.5 hours and Time C is 3 hours. I want the…
Prezza
  • 19
  • 2
  • 7
1
vote
0 answers

Dynamic allocation of weights to categories using Python

Problem statement : Dynamically allocate Pre-defined Weights on Categories in case of missing Category(ies). Details : there are 3 categories of data C1, C2 & C3 each having a predefined weight (lets say its 0.5 ,0.3 & 0.2 respectively). If data…
Shankar Pandey
  • 451
  • 1
  • 4
  • 22
1
vote
1 answer

Collapse data frame, by group, using lists of variables for weighted average AND sum

I want to collapse the following data frame, using both summation and weighted averages, according to groups. I have the following data frame group_id = c(1,1,1,2,2,3,3,3,3,3) var_1 = sample.int(20, 10) var_2 = sample.int(20, 10) var_percent_1…
SeánMcK
  • 392
  • 3
  • 17
1
vote
2 answers

Divide a weigthed average in a loop

Consider the following data: datamichael <- data.frame(x=c(100,200,300,500), y=c(75,100,300,400), row.names = LETTERS[1:4]) dataewan <- data.frame(x=c(200,50,200,600), y=c(100,100,400,300), row.names = LETTERS[1:4]) datatom <-…
user4773130
1
vote
1 answer

How to use the param of 'weights' of tensorflow function tf.contrib.legacy_seq2seq.sequence_loss_by_example?

The code: import tensorflow as tf A = tf.constant([[0.1,0.2,0.3,0.4],[0.2,0.1,0.4,0.3],[0.4,0.3,0.2,0.1],[0.3,0.2,0.1,0.4],[0.1,0.4,0.3,0.2]], dtype=tf.float32) B = tf.constant([1, 2, 1, 3, 3], dtype=tf.int32) w_1 = tf.constant(value=[1,1,1,1,1],…
1
vote
2 answers

Is it possible to load weight with definite amount or with an initializer in NN in keras in model.add?

Is it possible to load weight in NN in keras in model.add? I want to load the weight based on Xavier or another initializers. How I can do this in keras? For instance, weight=[w1,w2,w3,w4] how we could do this in keras? For instance, in TF we have:…
1
vote
1 answer

R: Weighted average with grouping and dependend from another variable

I think I need you help. I have a table like this: Product Price Quantity Quality 1 10 100 100 2 15 1200 88 1 12 88 95 Now, I want to calculate the average mean per…
Torte
  • 13
  • 4
1
vote
1 answer

Weighted average of dictionary values in python

I have a grid of parameters which is composed of 234 dictionaries, everyone having the same keys. Then I have a list of weights through which I want to compute a weighted average of such dictionaries' values. In other words I need to obtin just one…
AleB
  • 153
  • 1
  • 3
  • 10
1
vote
1 answer

Why are these means different when computed by dplyr mutate vs summarize in group_by?

My dataframe contains: a column deceased on which I compute aggregated means later on (mortality ratios, by gender) a weighting variable n.group a categorical sex (1: female, 2: male) I don't understand why the means and weighted-means m.mortf,…
chrischi
  • 185
  • 2
  • 8
1
vote
1 answer

Getting weighted average and standard deviation on several columns in Pandas

I am trying to do weighted standard deviation on top of weighted average on my pandas dataframe. I have a pandas dataframe like: import numpy as np import pandas as pd df = pd.DataFrame({"Date": pd.date_range(start='2018-01-01', end='2018-01-03…
ahoosh
  • 1,340
  • 3
  • 17
  • 31
1
vote
0 answers

PowerPivot: how to calculate a weighted average in a pivot table?

I am new to PowerPivot within Excel, but am familiar with SQL. I import a table from my SQL server into PowerPivot, containing the results of some surveys; the columns are: City, State, Population, avg income, avg income x population. I need to…
Pythonista anonymous
  • 8,140
  • 20
  • 70
  • 112
1
vote
1 answer

Multiple Correspondence Analysis on longitudinal data

I would like to explore the profile of two modalities of a categorical variable over time with respect to a given set of other categorical variables. I paste a reproducible example of such a dataset below. set.seed(90114) V1<-sample(rep(c("a", "A"),…
CBechet
  • 171
  • 2
  • 13
1
vote
0 answers

Is there an established method to weigh a weighted mean?

Problem. The weighted mean/average can be used to give differing weight in a mean computation to elements of differing importance. I need to figure out an extension that would in turn 'scale' or 'weigh' the resulting weighted mean with regards to…
user3554004
  • 1,044
  • 9
  • 24