Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

Standard deviation

Ads

 
 

Share on Google+Share on Google+

Supriya Kurian
Standard deviation
1 Answer(s)      6 years and 8 months ago
Posted in : Java Beginners

program to calculate the standard deviation of an array of values.the array elements are read from terminal.use function to calculate standard deviation and mean.

Ads
View Answers

December 10, 2010 at 1:39 PM


Hi Friend,

Try the following code:

import java.util.*;

public class StandardDeviation{
        public double findMean(int array[]){
        double total = 0;
        for(int i = 0; i < array.length; i++){
            total = total + array[i];
        }
        double mean = total/array.length;
        return mean;
    }
      public void findStandardDeviation(int array[]){
        double mean = findMean(array);
        System.out.println("Mean is: "+mean);
        double d1 = 0;
        double d2 = 0;
        double sum = 0;
            for(int i = 0; i < array.length; i++){
                d2 = (mean - array[i])*(mean - array[i]);
                d1 = d2 + d1;
            }
        System.out.println("Standard Deviation: " + Math.sqrt((d1/(array.length-1))));
            }

    public static void main(String args[]){
        Scanner input=new Scanner(System.in);
        System.out.println("Enter Array Elements: ");
        int array[] = new int[5];
        for(int i=0;i<array.length;i++){
            array[i]=input.nextInt();
        }
        StandardDeviation sd = new StandardDeviation();
        sd.findStandardDeviation(array);
        }
}

Thanks


Ads









Related Tutorials/Questions & Answers:
Standard deviation
Standard deviation  program to calculate the standard deviation of an array of values.the array elements are read from terminal.use function to calculate standard deviation and mean
standard format in C++
standard format in C++  Please help me with this one. thank you so much. **"Write a C++ program to read a date in US standard format (mm dd yyyy) and print it in Australia standard format (dd mm yyyy
Advertisements
spring standard tag libraries
spring standard tag libraries  hello sir please tell me how to write the jsp in Spring frame work using spring standard tag libraries
Version of taglibs>standard dependency
List of Version of taglibs>standard dependency
standard serviceregistrybuilder example
standard serviceregistrybuilder example  can any one share me the standard serviceregistrybuilder example code? My project is in Hibernate 4.3.1.... in Hibernate 4.3.1?. It will explain you how to use the standard
Joomla Standard Package
Joomla Standard Package In this package we offer a complete standard package that can be customize or upgraded later as per the requirement of the clients. The client itself can modify and manage
standard action - JSP-Servlet
standard action  Any one please tell me what is the function of standard actions tags and the deatils of its atrributes along with example. ... or a standard tag. For Example : Action may display an output or write some value
the standard isolation levels defined by JDBC
the standard isolation levels defined by JDBC  What are the standard isolation levels defined by JDBC
Replace JSF Standard Error Message
Replace JSF Standard Error Message  How can we replace the JSF Standard Error Message
Version of taglibs>standard-doc dependency
List of Version of taglibs>standard-doc dependency
Version of taglibs>standard-examples dependency
List of Version of taglibs>standard-examples dependency
Version of com.inkapplications>android-standard dependency
List of Version of com.inkapplications>android-standard dependency
Version of com.theoryinpractise>halbuilder-standard dependency
List of Version of com.theoryinpractise>halbuilder-standard dependency
Java 2 SDK, Standard Edition,
Java 2 SDK, Standard Edition,  Once I have the Java 2 SDK, Standard Edition, from Sun, what else do I need to connect to a database
Maven Dependency standard >> 1.0
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard version1.0 in your project
Maven Dependency standard >> 1.0.1
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard version1.0.1 in your project
Maven Dependency standard >> 1.0.2
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard version1.0.2 in your project
Maven Dependency standard >> 1.0.3
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard version1.0.3 in your project
Maven Dependency standard >> 1.0.4
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard version1.0.4 in your project
Maven Dependency standard >> 1.0.5
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard version1.0.5 in your project
Maven Dependency standard >> 1.0.6
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard version1.0.6 in your project
Maven Dependency standard >> 1.1.0
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard version1.1.0 in your project
Maven Dependency standard >> 1.1.1
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard version1.1.1 in your project
Maven Dependency standard >> 1.1.2
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard version1.1.2 in your project
java standard edition - Java Beginners
java standard edition  good evening sir. i want to install j2se version-6 on my laptop and netbeans, so i want to know the path: and classpath: to type in the environmental variables Dialogue box. also full details about
Maven Dependency standard-doc >> 1.0
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard-doc version1.0 in your project
Maven Dependency standard-doc >> 1.0.4
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard-doc version1.0.4 in your project
Maven Dependency standard-doc >> 1.1.0
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard-doc version1.1.0 in your project
Maven Dependency standard-examples >> 1.0.3
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard-examples version1.0.3 in your project
Maven Dependency standard-examples >> 1.0.6
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard-examples version1.0.6 in your project
Maven Dependency standard-examples >> 1.1.2
You should include the dependency code given in this page to add Maven Dependency of taglibs >> standard-examples version1.1.2 in your project