average

get average from set of objects in django

Hay, i have a simple rating system for a property. You give it a mark out of 5 (stars). The models are defined like this def Property(models.Model) # stuff here def Rating(models.Model) property = models.ForeignKey(Property) stars = models.IntegerField() What i want to do is get a property, find all the Rating objects, co...

Get the AVG of two SQL Access Queries

Hi, I'm trying to get the AVERAGE from the results of two separate sql queries built in MS Access. The first sql query pulls the largest record: SELECT DISTINCTROW Sheet1.Tx_Date, Sheet1.LName, Sheet1.Patient_Name, Sheet1.MRN, Max(Sheet1.) AS [Max Of FEV1_ACT], Max(Sheet1.FEF_25_75_ACT) AS [Max Of FEF_25_75_ACT] FROM Sheet1 GROUP ...

How is IObservable<double>.Average supposed to work?

Update Looks like Jon Skeet was right (big surprise!) and the issue was with my assumption about the Average extension providing a continuous average (it doesn't). For the behavior I'm after, I wrote a simple ContinuousAverage extension method, the implementation of which I am including here for the benefit of others who may want somet...

Using exponential smoothing with NaN values

I have a sample of some kind that can create somewhat noisy output. The sample is the result of some image processing from a camera, which indicates the heading of a blob of a certain color. It is an angle from around -45 to +45, or a NaN, which means that the blob is not actually in view. In order to combat the noisy data, I felt that ...

MySQL : AVG of AVG impossible ?

Hi, I want to do an average : the problem is for 1 item i'm calculating the AVG of each elements (working) but as soon as i want the GLOBAL average of the averages of the categories (something and foo) it doesn't work (mysql throw me an error : see the syntax i used just below). I need to do that because i want to sort the result by th...

Haskell dot operator

I try to develop a simple average function in Haskell. This seems to work: lst = [1, 3] x = fromIntegral (sum lst) y = fromIntegral(length lst) z = x / y But why doesn't the following version work? lst = [1, 3] x = fromIntegral.sum lst y = fromIntegral.length lst z = x / y ...

Simple average calculation

I'm trying to write program calculating average of given numbers stored in an array. Amount of numbers should be not more than 100, and user should input them until a !int variable is given : #include <iostream> #include <conio.h> using namespace std; double average(int tab[], int i){ int sum=0; for(int j=0; j<i; ++j){ ...

Average function without overflow exception

.NET Framework 3.5. I'm trying to calculate the average of some pretty large numbers. For instance: using System; using System.Linq; class Program { static void Main(string[] args) { var items = new long[] { long.MaxValue - 100, long.MaxVal...

Compute weighted averages for large numbers

I'm trying to get the weighted average of a few numbers. Basically I have: Price - 134.42 Quantity - 15236545 There can be as few as one or two or as many as fifty or sixty pairs of prices and quantities. I need to figure out the weighted average of the price. Basically, the weighted average should give very little weight to pairs...

Averaging increasing number of variables

Hi! I have to report average value of incoming numbers, how i could do that without using some sort of data structure to keep track of all values and then calculating average by summing them and dividing by number of values? ...

MySQL Daily Average over a month

I'm pulling several status over a specific time period and I'd like to pull another stat that would be "average sales per day" over this time period. I'm not sure how to do daily averages over a specific time period, can anyone provide some advice? $whereSql = 'WHERE created >= '.$endTimestamp.' AND created <= '.$startTime...

Average of grouped rows in Sql Server

Hi there. I have an Sql Server Table.. it's something like this: Id ...... Column1 ...... Column2 ```````````````````````````````` 1 ........ 1 ............. 34 2 ........ 1 ............. 44 3 ........ 2 ............. 45 4 ........ 2 ............. 36 5 ........ 2 ............. 23 6 ........ 3 ............. 68 7 ..........

Java Time Specific Average

I have a text file: DATE 20090105 1 2.25 1.5 3 3.6 0.099 4 3.6 0.150 6 3.6 0.099 8 3.65 0.0499 DATE 20090105 DATE 20090106 1 2.4 1.40 2 3.0 0.5 5 3.3 0.19 7 2.75 0.5 10 2.75 0.25 DATE 20090106 DATE 20090107 2 3.0 0.5 2 3.3 0.19 9 2.75 0.5 DATE 20100107 On each day I have: Time Rating Variance I want to work out the average variance...

TSQL Average Column By Distinct Entries In Another Column

I start with a table looking like this... +-------------------------+ | procName | TimeEnded | +-------------------------+ | A | 04:00:00.000 | | B | 04:01:00.000 | | C | 04:03:00.000 | | A | 04:06:00.000 | | B | 04:10:00.000 | | ... | ... | Run a query to generate a RunTime column,...

prevent long running averaging from overflow?

suppose I want to calculate average value of a data-set such as class Averager { float total; size_t count; float addData (float value) { this->total += value; return this->total / ++this->count; } } sooner or later the total or count value will overflow, so I make it doesn't remember the total value by : cl...

Counting all other types but the current one

Hi, I'm trying to write this query, that would calculate the average value of all the columns except the one that contains the type value, which I'm grouping the whole query by. So for 4 types for example, each column in the resulting table will contain the average of all the other three type's values, i need to exclude the current type...

.NET Linq to SQL: select average with where-clause

Hi, I'have a table with movies, which has an integer attribute called ranking. I'd now like to retrieve the average ranking from all movies containing a certain actor. Dim q2 = (From p In dc.Movies Where p.actlist.Contains(actor.name) Select p.ranking).Average() This query doesn't work - Overload resolution failed because no accessi...

How to GroupBy 2 values in a Generic list, VB.NET ?

I'm using VB.NET on Framework 2.0. I'm looking to quickly group a Generic List<> by two properties. For the sake of this example lets say I have a List of an Order type with properties of CustomerId, ProductId, and ProductCount. How would I get the average of ProductCounts grouped by CustomerId and ProductId in VB.NET ? Unfortunatly I c...

Awk array assistance needed - averaging.

Here is an example of the type of data that I am trying to manipulate: 1213954013615]: 992 1213954013615]: 993 1213954013615]: 994 1213954013615]: 995 1213954013615]: 995 1213954013615]: 996 1213954013615]: 996 1213954013615]: 996 1213954013615]: 998 1213954247424]: 100 1213954247424]: 1002 1213954247424]: 1007 1213954303390]: 111 12139...

what function or loop do I have to use to average the matrix?

Hey I want to find the average of all the matrix: Data=(Data{1}+......+Data{n})/n) where Data{n} is a matrix of m*n.. Thank you sooo much ...