Results 1 to 2 of 2
Like Tree3Likes
  • 3 Post By DarrylBurke

Thread: standard deviation in java

  1. #1
    noobplus's Avatar
    noobplus is offline Senior Member
    Join Date
    Feb 2012
    Location
    chennai,south of India(south east of asia)
    Posts
    232
    Rep Power
    3

    Default standard deviation in java

    hi
    standard deviation formula is standard deviation in java-c9e0adcb225ae01490f9da4430fcbfa5.png

    I've x-values in yArray[]
    and the code shows errors
    and ive almost broken my head

    Java Code:
    	    double avgT=0;
    	    double avgT2=0;
    	    double[] SD =new double[TotalLineCount/4];//totallinecount is the number of lines in my input text file 
    for(int j=0;j<TotalLineCount;j=j+4)
    	    	  {
    	    		
    	    	     for(int k=j+0;k<j+4;k++)   //for every 4 values, Standard Deviation is found
    	    	       {
    	    	    	 System.out.println(avgT);
    	    	    	 avgT=ReadPlatInstance.yArray[k]+avgT;  //this is E(X^2)
    	    	    	 System.out.println(avgT);
    	    		     avgT2=(ReadPlatInstance.yArray[k]*ReadPlatInstance.yArray[k])+avgT2;  //this is E(X)
    	    		     System.out.println("\t k is "+k);	    		    
    	    	        }
    	    	     SD[j]=Math.sqrt(((avgT2/4)-((avgT/4)*(avgT/4)))/((4)*(4-1)));  //this part shows wrong answer. i've checked with "stdev" function in excel.
    i would get relaxed for a second, if u tell me the error in the code

    thanks
    dhilip
    Last edited by noobplus; 03-17-2012 at 05:25 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: standard deviation in java

    Quote Originally Posted by noobplus View Post
    i'd get relax a second if u temme the error in the code

    thx
    Please don't use non standard abbreviations in place of common words. This is a programming forum, not an SMS chat relay.

    db
    noobplus, ojn and Bestsanchez like this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 15
    Last Post: 02-13-2012, 09:00 PM
  2. standard deviation error
    By rochla16 in forum New To Java
    Replies: 2
    Last Post: 05-03-2011, 04:43 AM
  3. standard deviation calculation
    By rochla16 in forum New To Java
    Replies: 5
    Last Post: 04-28-2011, 07:27 PM
  4. [SOLVED] Calculating Std. Deviation using Java
    By random0munky in forum New To Java
    Replies: 1
    Last Post: 12-12-2008, 09:24 AM
  5. standard deviation and mean for an array
    By peterdfl in forum New To Java
    Replies: 3
    Last Post: 05-29-2008, 04:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •