array(find average and median)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wonderaz
Forum Newbie
Posts: 2
Joined: Tue Jan 09, 2007 12:10 am

array(find average and median)

Post by wonderaz »

Hello....

I need to find out the average and median of the parameter array

I only manage to find the total of that array by using array_sum()
Can anyone please give me idea on how to create a function to solve my problem?

Thanks :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

count() and sort() will be used. Do you need further nudging?
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

Remember, the average is adding them all and dividing by the count, and the median is the "physical" location of the center point, or using interpolation, a value in between the middle two values... Finding the Quartiles/IQR would be done in the exact same matter.
Post Reply