weighted-average

How to add a weighted average summary to a DevExpress XtraGrid?

 ̄綄美尐妖づ 提交于 2019-12-04 16:10:44
The DevExpress Grid (XtraGrid) allows grids and their groups to have summary calculations. The available options are Count, Max, Min, Avg, Sum, None and Custom. Has anyone got some sample code that shows how to calculate a weighted average column, based upon the weightings provided as values in another column? I ended up working this out, and will post my solution here in case others find it useful. If a weighted average consists of both a value and a weight per row, then column that contains the value should have the weight GridColumn object assigned to its Tag property. Then, this event

How do I calculate a weighted average in mongoDB using aggregation framework?

二次信任 提交于 2019-12-04 15:57:20
问题 I need to calculate weighted average over a set of documents. Each document contains both a weight and a value in a separate field. Here is an example: I have following 2 documents representing a sales transaction. { quantity : 3, price : 2 } { quantity : 9, price : 6 } I want to find the average price for both transactions. This is a weighted average where weight is the quantity and value is the price. This can be calculated by AveragePrice = (3 * 2 + 9 * 6 ) / (3 + 9) . How do I perform

How to calculate scores?

↘锁芯ラ 提交于 2019-12-04 10:40:31
问题 This question is more related to logic than any programming language. If the question is not apt for the forum please do let me know and I will delete this. I have to write a logic to calculate scores for blogs for a Blog Award website. A blog may be nominated for multiple award categories and is peer-reviewed or rated by a Jury on a -1 to 5 scale (-1 to indicate a blog they utterly dislike). Now, a blog can be rated by one or more Jurors. One criterion while calculating final score for a

Calculating Weighted Average with LINQ

时光总嘲笑我的痴心妄想 提交于 2019-12-03 18:00:19
问题 My goal is to get a weighted average from one table, based on another tables primary key. Example Data: Table1 Key WEIGHTED_AVERAGE 0200 0 Table2 ForeignKey Length Value 0200 105 52 0200 105 60 0200 105 54 0200 105 -1 0200 47 55 I need to get a weighted average based on the length of a segment and I need to ignore values of -1. I know how to do this in SQL, but my goal is to do this in LINQ. It looks something like this in SQL: SELECT Sum(t2.Value*t2.Length)/Sum(t2.Length) AS WEIGHTED_AVERAGE

Calculating weighted moving average using pandas Rolling method

若如初见. 提交于 2019-12-03 08:44:55
I calculate simple moving average: def sma(data_frame, length=15): # TODO: Be sure about default values of length. smas = data_frame.Close.rolling(window=length, center=False).mean() return smas Using the rolling function is it possible to calculate weighted moving average? As I read in the documentation , I think that I have to pass win_type parameter. But I'm not sure which one I have to choose. Here is a definition for weighted moving average. Thanks in advance, Yeah, that part of pandas really isn't very well documented. I think you might have to use rolling.apply() if you aren't using one

How to calculate scores?

耗尽温柔 提交于 2019-12-03 06:23:59
This question is more related to logic than any programming language. If the question is not apt for the forum please do let me know and I will delete this. I have to write a logic to calculate scores for blogs for a Blog Award website. A blog may be nominated for multiple award categories and is peer-reviewed or rated by a Jury on a -1 to 5 scale (-1 to indicate a blog they utterly dislike). Now, a blog can be rated by one or more Jurors. One criterion while calculating final score for a blog is that if a blog is rated positively by more people it should get more weightage (and vice-versa).

algorithm used to calculate 5 star ratings

浪子不回头ぞ 提交于 2019-12-03 01:33:57
问题 I need to calculate 5-star ratings like the one on Amazon website. I have done enough search to find what is the best algorithm, but I am not able to get a proper answer. For example, if these are the ratings 5 star - 252 4 star - 124 3 star - 40 2 star - 29 1 star - 33 totally 478 reviews Amazon has calculated this to be "4.1 out of 5 stars". Can anyone tell me how this figure is arrived at? I am not able to get this just by doing average. 回答1: That's a weighted average, where you weigh each

How to calculate time-weighted average and create lags

坚强是说给别人听的谎言 提交于 2019-12-02 17:14:43
问题 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 each individual into the study. For each row the one year exposure assignment should include data from the preceding 12 months starting from the last month before joining the study. As an example the first person in the sample data joined the study on

algorithm used to calculate 5 star ratings

北慕城南 提交于 2019-12-02 13:52:12
I need to calculate 5-star ratings like the one on Amazon website. I have done enough search to find what is the best algorithm, but I am not able to get a proper answer. For example, if these are the ratings 5 star - 252 4 star - 124 3 star - 40 2 star - 29 1 star - 33 totally 478 reviews Amazon has calculated this to be "4.1 out of 5 stars". Can anyone tell me how this figure is arrived at? I am not able to get this just by doing average. That's a weighted average, where you weigh each rating with the number of votes it got: (5*252 + 4*124 + 3*40 + 2*29 + 1*33) / (252+124+40+29+33) = 4.11

pandas: groupby and variable weights

断了今生、忘了曾经 提交于 2019-12-01 08:21:12
I have a dataset with weights for each observation and I want to prepare weighted summaries using groupby but am rusty as to how to best do this. I think it implies a custom aggregation function. My issue is how to properly deal with not item-wise data, but group-wise data. Perhaps it means that it is best to do this in steps rather than in one go. In pseudo-code, I am looking for #first, calculate weighted value for each row: weighted jobs = weight * jobs #then, for each city, sum these weights and divide by the count (sum of weights) for each city: sum(weighted jobs)/sum(weight) I am not