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
    chennai,south of India(south east of asia)
    Rep Power

    Default standard deviation in java

    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
    	    	    	 avgT=ReadPlatInstance.yArray[k]+avgT;  //this is E(X^2)
    	    		     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

    Last edited by noobplus; 03-17-2012 at 06:25 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    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

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

    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, 10:00 PM
  2. standard deviation error
    By rochla16 in forum New To Java
    Replies: 2
    Last Post: 05-03-2011, 05:43 AM
  3. standard deviation calculation
    By rochla16 in forum New To Java
    Replies: 5
    Last Post: 04-28-2011, 08:27 PM
  4. [SOLVED] Calculating Std. Deviation using Java
    By random0munky in forum New To Java
    Replies: 1
    Last Post: 12-12-2008, 10:24 AM
  5. standard deviation and mean for an array
    By peterdfl in forum New To Java
    Replies: 3
    Last Post: 05-29-2008, 05: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