Jump to content

standard deviation using array

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
forever

forever

    Newbie

  • Members
  • Pip
  • 8 posts
hello
I have this java program I tried to make it complete it but I found lot of error to get n integer value
& find standard deviation using array
if any one no please help me
import java.util.*;

  public class Sd{

  public static void main(String[]args){

  Scanner scan=new Scanner(System.in);

   

   

  

    int z =0;

    int sum=0;

   int average=0;

    int y ;

  

    int[]sd=new int [11];

    for (int i=1; i< sd.length ; i++){

    System.out.println("Enter sd of " +i );

    sd[i]= scan.nextInt();

    }

        

    for (int i=1; i<11 ;i++)

      sum = sum + sd[i];

    

    for (int i=1; i<11 ; i++)

       System.out.println("x[" + i +"]=" + sd[i]);

    System.out.println("The total  is " + sum);

    

    average = sum / sd.length;

    

    System.out.println(" average is 2"+  average ); 

    

   for (int i=1; i<11;i++)

       z = sd[i] - average; 

    

    double a= Math.pow(z,2);

    

    System.out.println( z );

    System.out.println(a);

     


#2
Sinipull

Sinipull

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 386 posts
It's really hard to understand what you want, or what's wrong with your program.

The first thing that i noticed, is that you start filling your array from index 1, but array actually starts from index 0.

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
1) standard deviation usually is NOT an integer, nor is the mean. All these calculations should be done on floats.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
forever

forever

    Newbie

  • Members
  • Pip
  • 8 posts

Sinipull said:

It's really hard to understand what you want, or what's wrong with your program.

The first thing that i noticed, is that you start filling your array from index 1, but array actually starts from index 0.

why it is hard just i want to make a program to solve standard divation it eguation like this sequare root of sum(x-Average)^2/n-1 using the array

#5
forever

forever

    Newbie

  • Members
  • Pip
  • 8 posts

WingedPanther said:

1) standard deviation usually is NOT an integer, nor is the mean. All these calculations should be done on floats.

thanks for ur advice o will consider this
and if you now the code please write it down

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Make the change I told you to make to your code, and see if your results improve.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog