I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
Index » Programming » C/C++ »

Need syntax for MEDIAN

skydivetom\′s Photo
15 Sep 07, 3:49PM
(1 reply)
Need syntax for MEDIAN
I need to calculate the Median in a C routine.

My pseudo code would look like (I think)... where cnt1[i] my array:

if cnt1[i] = even number then [(cnt1[i]) + (cnt1[i] -1)] /2 else cnt1[i] /2 end

I'm new to C and have no idea as to how the actual syntax should look like. Any ideas?

skydivetom
will\′s Photo
27 Sep 07, 9:09AM
Take a look at:

http://www.codecogs.com/d-ox/stats/moments/median.php

In essence you run through the data and find the n/2 th smallest number. Or largest!

Hope this helps.

Will

Currently you need to be logged in to leave a message.