title: Java Programming, Statistical Methods
body: <p>So I'm doing this code for a school project and my code keeps screwing up.  It happens in the fillRandomArray method and I get two errors, a misplaced construct on the while loop, and then an error telling me to remove the curly bracket enclosing the loop.  I basically want the loop to go through just those 4 statements and fill up the array with values with 3 standard deviations.  Then afterwards, I'll go off and subtract to create a pseudo-normal curve.</p>
  
  <pre><code>   import javax.swing.*;
     import java.util.*;
     import java.util.Arrays;
     public class statisticalModel
     {
      //Initates a place for the normal curve to be placed.
      static double Ho;
      //Real proportion of data statistic.
      static double Ha;
      //Estimated real proportion of data statistic.
      static int Pop;
      //Population size.
      static int Zscore;
      //Z score, or the amount of standard deviations away from the mean.
      //Z score = sqrt(P(1-p)/N)
      static int stdDev;
      //Standard Deviation, follows the 65, 95, 99 model.  65 percent of all    scores
      //fall in one standard deviation of the mean.  95 percent of all scores fall
      //within two standard deviations of the mean.  99 percent of all scores fall
      //within three standard deviations of the mean.
      static int mean;
      //The average of all the scores of the array.
      static double variance;
      //The average difference between sets of values within the array.
      static String desiredValue = "";
      //This is a string set to the user's command.  Tells whether or not the  value should
      //be lower than, higher than, or not equal to Ho.
      static int[] meanScores = new int[100];
      //Array meant to generate a set of random values within the normal curve of
      //the model, following the 65, 95, 99 rule.
      static Scanner sc =new Scanner(System.in);
      //Scanner to take in values listed above.  
      static World wor ;
      //Screen which the normal curve is printed on.
      static int size;
      //Variable that measures the size of the array.
      static int temporary;
      //Value Holder for For Loops, While Loops, If Statements, etc.
      public static void main(String args[])
      {
       size = meanScores.length;
       wor = new World(600,600);
       Turtle cursor;
       cursor = new Turtle(300, 500 ,wor);
       runStatisticalMethod();
       System.out.println(Arrays.toString(meanScores));
      }
      public static void runStatisticalMethod()
      {
       takeInData();
       calculateStats();
       generateCurve();
       explainSolution(); 
  
      }
      public static void takeInData()
      {
      System.out.println("Please enter your desired Ho");
      Ho = sc.nextDouble();
      System.out.println("Please enter your desired Ha");
      Ha = sc.nextDouble();
      System.out.println("Please enter your desired population size");
      Pop = sc.nextInt();
      System.out.println("Thanks for entering your data.  Your data will be   compiled below");  
  
      }
      //Generates a normal curve based on the data from calculateStats() and
      //data entered by the user.
      public static void generateCurve()
      {
       fillRandomArray();
       //Functions as a cursor to draw the normal curve
       for(int x = 0; x &lt; 99; x++)
       {
  
  
  
       }
  
      }
      //Fills the array meanScores with random integers.
      public static void fillRandomArray()
      {
       double x = 0.0;
       while(x &lt; 100.0)
       {
        (double)randomValue = (Math.random()*100);
        meanScores[x] = randomValue;
        meanScores[x]= meanScores[x]*(stdDev*(Math.random()*3));
        x++;
       }
       assignStdDev();
       for(double x = 0.0; x &lt; 99.0; x++)
       {
        for(double y = 0.0; y &lt; 99.0; y++)
        {
         if(meanScores[y] &gt;= meanScores[y+1])
         {
          double valueHolder1 = meanScores[y];
          double valueHolder2 = meanScores[y+1];
          meanScores[y+1] = valueHolder1;
          meanScores[y] = valueHolder2; 
  
         }
        }
       }
       System.out.println("The following is a set of 100 random values which follow the normal curve of your hypothesis");
      }
      public static void assignStdDev()
      {
       for(int x = 5; x &gt;=5 &amp;&amp; x &lt;=95; x++)
       {
        meanScores[x] = meanScores[x] - (int)(stdDev*Math.random());
       }
       for(int x = 31; x &gt;= 31 &amp;&amp; x &lt; 66; x++)
       {
       meanScores[x] = meanScores[x] - (int)(stdDev*Math.random());
       }  
      }
      //Calculates a set of statistics including standard deviation, z-score, mean,
      //interquartile range, probability, and variance.
      public static void calculateStats()
      {
        //Calculates the Mean of the inputted variables and normal curve.
       int sum = 0;
       for(int a : meanScores)
       {
        sum += a;
       }
       mean = sum/size;
       //Calculate the Variance of the inputted variables and normal curve.
       for(int b :meanScores)
       {
        temporary += (b-mean)*(b-mean);
       }
       variance = temporary/size;
       //Calculate the Standard Deviation of the inputted variables and normal curve.
       stdDev = (int)Math.sqrt(variance);
      }
      //This method explains the numbers generated in terms of statistics and analyzes
      //if the hypothesis is probably.  If not, a possible solution is proposed with
      //regards to what should be changed.  Also explains the curve of the graph.
      public static void explainSolution()
      {
  
  
      }
    }
  </code></pre>