473,320 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Median and Mean

MS
OK, calculating the mean from a set of numbers is easy.

Anyone have formula for calculating the median?

Ok, ok, I didn't do well at maths! :-(
Nov 13 '05 #1
3 3220
On Thu, 17 Mar 2005 21:34:44 GMT, "MS" <Em***@Myemail.com> wrote:
OK, calculating the mean from a set of numbers is easy.

Anyone have formula for calculating the median?
Sort the array of values (ascending or descending, doesn't matter)

Midpoint is the median (if odd number of elements)

If there are an even number of elements, take half-way between the two
values in the middle.
Ok, ok, I didn't do well at maths! :-(


There is a built in function (statistical) in Excel if you want to
transfer the data there for the calculations....
James

Nov 13 '05 #2
MS wrote:
OK, calculating the mean from a set of numbers is easy.

Anyone have formula for calculating the median?

Ok, ok, I didn't do well at maths! :-(


I haven't found a way to do it in a single query, but I found a way
using two queries:

tblValues
ID AutoNumber
Value Double

qryRankForMedian:
SELECT tblValues.Value, (SELECT Count(A.ID) FROM tblValues AS A WHERE
A.Value < tblValues.Value) + (SELECT Count(A.ID) FROM tblValues AS A
WHERE A.Value = tblValues.Value AND A.ID < tblValues.ID) + 1 AS
Ranking, (SELECT Count(*) FROM tblValues) / 2 + 0.5 AS WantRanking FROM
tblValues;

qryMedian:
SELECT Avg(qryRankForMedian.Value) AS Median FROM qryRankForMedian
WHERE ((Abs([Ranking]-[WantRanking])<0.6));

I haven't tested it out completely but it ran on all the examples I
tried.

James A. Fortune

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ross Contino | last post by:
Hello to all: I have been searching the web for examples on how to determine a median value in a mySQL table. I have reviewed the article at...
8
by: nick.vitone | last post by:
Hi, I'm somewhat of a novice at Access, and I have no experience programming whatsoever. I'm attempting to calculate the statistical median in a query. I need to "Group by" one column and find...
2
by: Drebin | last post by:
I'm looking for mean, median, mode and standard deviation - maybe a couple methods that take in an array of floats or something?? Thanks much!
4
by: uspensky | last post by:
I have a table (cars) with 3 fields: VIN, Class, sell_price 101, sports, 10000 102, sports, 11000 103, luxury, 9000 104, sports, 11000 105, sports, 11000 106, luxury, 5000 107, sports, 11000
5
by: jonm4102 | last post by:
I'm trying to calculate the median of some numerical data. The data can only be found in a query (henceforth query 1) field I previously made, and I would prefer to calculate the median in a new...
5
by: Yannick Tremblay | last post by:
Hi, I have a std::map<id, timestampcollection. The id is the normal reference so the key-value ordering is correct. However, once in a blue moon, I want to prune this collection. So that...
3
by: Scott | last post by:
I need to take the median from a field of records in a report. Can someone shed the light how to do it. Thanks, Scott
7
by: Bhadan | last post by:
Hello, I have several jagged arrays which have been sorted. I'm trying to find the median of each array. Any tips appreciated. TIA. Bhads.
3
by: mehwishobaid | last post by:
i dont know wat is wrong with my code. when i compile. i get the error saying line 29: error: expression must have pointer-to-object type #include <iostream> using namespace std; #include...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.