943,973 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1395
  • Java RSS
Nov 7th, 2009
0

mean and standard deviation confused

Expand Post »
I am really confused by this problem. PLEASE HELP

Write a program that reads a set of floating point data values from the input. When the user indicates the end of the input, print out the count if the values, the average, and the standard deviation. The average of a data set is x1,......,xn is

t = Σxi/n

where Σx1 = x1+...+xn is the sum of the input values. The standard deviation is:

s=Math.sqrt(Σxi^2 - (1/n)*(Σxi)^2/n-1)

my professor asks me to Create a method in the class Mymath to print out the count of values, the average, and the standard deviation. Use the numerically less stable formula to find the standard deviation.

and this is what the output should be:

1
2
3
4
5
6
-1

Count of values: 6
Average: 3.50
Standard Deviation: 1.87
Similar Threads
Reputation Points: 9
Solved Threads: 0
Newbie Poster
kulrik is offline Offline
15 posts
since Oct 2009
Nov 7th, 2009
0
Re: mean and standard deviation confused
So which part are you confused about? Reading in the values? Calculating the formulas? The formulas are standard formulas, so if you don't get them, just look up those terms on google and you'll find plenty of explanations. Your professor didn't make those up. And to read in the values, you can make a Scanner. Test each value read in; if it is -1, stop reading in values, and do not include the -1 value in your calculations. So you'll basically be using a while loop to read in all the values, then adding them to an ArrayList<Integer>.
Reputation Points: 874
Solved Threads: 352
Posting Maven
BestJewSinceJC is offline Offline
2,758 posts
since Sep 2008
Nov 7th, 2009
0
Re: mean and standard deviation confused
im just confused on how to do it. i guess i need a jump start thats all.
Reputation Points: 9
Solved Threads: 0
Newbie Poster
kulrik is offline Offline
15 posts
since Oct 2009
Nov 7th, 2009
0
Re: mean and standard deviation confused
  1. Get the count
  2. Calculate the sum
  3. From the count and the sum, calculate the average.
  4. From the average, get each deviation (error).
  5. Square each deviation (squared error).
  6. Add up the squares (sum of squared errors).
  7. Divide by (count - 1) (mean squared error. count - 1 is degrees of freedom).
  8. Take the square root.
  9. You now have the standard deviation.


Slightly different formula/method than the one you listed, but if you do some math, I imagine you'll find that they are equivalent and will give identical results.
Last edited by VernonDozier; Nov 7th, 2009 at 3:04 pm.
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,375 posts
since Jan 2008
Jul 28th, 2010
-1
Re: mean and standard deviation confused
WRIGHT A PROGRAM IN C WHICH REQUEST SCORES STORES THEM IN AN ARRAY , THEN IT CALCULATES THE MEAN, Deviations FROM MEAN, STD DEVIATION AND THEN IT PRINTS THE THREE(MEAN, AVERAGE, DEVIATIONS, STD DEVIATION.)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
WILSONOTIENO46@ is offline Offline
1 posts
since Jul 2010
Jul 28th, 2010
0
Re: mean and standard deviation confused
WRIGHT A PROGRAM IN C WHICH REQUEST SCORES STORES THEM IN AN ARRAY , THEN IT CALCULATES THE MEAN, Deviations FROM MEAN, STD DEVIATION AND THEN IT PRINTS THE THREE(MEAN, AVERAGE, DEVIATIONS, STD DEVIATION.)
Don't yell( meaning don't use capitals) we are not DEAF.
Also start a new thread.
Also this is a java forum not a C forum.
Also post some code. Don't expect someone to give you the answer. If you don't know where to start, explain specifically what is your problem
Sponsor
Featured Poster
Reputation Points: 1014
Solved Threads: 446
Nearly a Senior Poster
javaAddict is online now Online
3,259 posts
since Dec 2007
Jul 28th, 2010
0
Re: mean and standard deviation confused
On Nov. 7th VernonDozier has clearly and correctly indicated the steps in writing a code to calculate. Please following the instruction write your own program.
Reputation Points: 34
Solved Threads: 72
Posting Whiz
tong1 is offline Offline
358 posts
since Jul 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: redirecting standart output to .txt
Next Thread in Java Forum Timeline: SQL Sentence in executeQuery





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC