Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Standard deviation
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Supriya Kurian
Standard deviation
1 Answer(s)      3 years and 9 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.


Advertisement
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



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
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
Replace JSF Standard Error Message
Replace JSF Standard Error Message  How can we replace the JSF Standard Error Message
the standard isolation levels defined by JDBC
the standard isolation levels defined by JDBC  What are the standard isolation levels defined by JDBC
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
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
JSP Standard Actions
JSP Standard Actions In this section, we will learn about JSP standard Action & their elements with some examples. JSP Standard action are predefined..., to generate a browser-specific code, etc. The JSP standard actions affect the overall
Standard Action "jsp:param"
Standard Action <jsp:param> In this Section, we will discuss about "jsp:param" standard action & their utilization with a example. Basically, <jsp:param> is use to pass one or more name/value pairs as request
Command Line Standard Output In Java
Command Line Standard Output In Java In this section we will discuss about the Command Line Java IO Standard Output. Standard streams, feature of various O/S, are written through standard output in Java. Standard streams can
Java Standard Edition
Java Standard Edition Java, Standard Edition also called Java SE is commonly... standard edition comprise of a virtual machine, which is put in practice for running... different applications. Before getting its present name Java Standard Edition 6.0
how to parse a csv file using standard libraries?
how to parse a csv file using standard libraries?  hie i am a beginner in java i want to parse a csv file using any standard libraries i want to know how the libraries are imported and used in eclipse thanks in advance
Command Line Standard Error In Java
Command Line Standard Error In Java In this section we will discuss about the Command Line Java IO Standard Error. System.out and System.err both are for Standard output but, System.err separates the error output. System.err
Standard Action "jsp:plugin"
Standard Action <jsp:plugin> In this Section, we will discuss about standard action "jsp:plugin" & their implementation using a example...:plugin>' standard action. pluginstandardaction.jsp <
Standard Edition Networked Application - Java Beginners
Standard Edition Networked Application   I Develope a School Automated System on standard edition that takes a details from the user interface and deposited into the database (MSSQL), i make the registrar to be able to upload
Standard Edition Networked Application - Java Beginners
Standard Edition Networked Application   I Develope a School Automated System on standard edition that takes a details from the user interface and deposited into the database (MSSQL), i make the registrar to be able to upload
Command Line Standard Input In Java
Command Line Standard Input In Java In this section we will discuss about the Java IO Standard Input through Command Line. Standard streams, feature of various O/S, are read through standard input in Java. Standard streams are read
Read Text from Standard IO
Reading Text from the Standard Input       Standard Streams: Standard Streams... operations on files.  Java also supports three Standard Streams
Fetch the data using jsp standard action
Fetch the data using jsp standard action  I want the code of fetch the data from the database & show in a jsp page using jsp:usebean in MVC model 2 architecture. Suppose after login a user can view his/her details which he
JSP Standard Action 'jsp:useBean'
JSP Standard Action <jsp:useBean> This action let you use java bean... STANDARD ACTION</strong></h3> </td> </tr>... standard Actions :<jsp:setProperty> & <jsp:getProperty>
JSP Standard Tag Libraries (JSTL)
JSP Standard Tag Libraries (JSTL)       JSTL is developed under the Java Community Process... and standard set of custom tags. It encapsulates simple tags as the common core
use JDBC to execute non-standard features that my DBMS provides.
use JDBC to execute non-standard features that my DBMS provides.  Can I use JDBC to execute non-standard features that my DBMS provides
JSP Standard Actions 'jsp:setProperty' & 'jsp:getProperty'
JSP Standard Actions <jsp:setProperty> & <jsp:getProperty>..., boolean, Boolean, byte, Byte, char, and Character via the standard valueOf...; <h3><strong>EXAMPLE OF JSP:USEBEAN STANDARD ACTION<
Write Log Records to Standard Error in Java
Write Log Records to Standard Error in Java   ... to standard error in Java. Java provides the facility for handling an error... or publishes log records on the standard error which is written in the log file
retrieving image from mysql db with standard height and width
retrieving image from mysql db with standard height and width  Hi . Here is my code to retrieve an image from mysql db. Its working properly. But i want the image with specified width and height. How to specify it in this code
retrieving image from mysql db with standard height and width
retrieving image from mysql db with standard height and width  Hi . Here is my code to retrieve an image from mysql db. Its working properly. But i want the image with specified width and height. How to specify it in this code
Need the program urgent veryyyyyyyyyyyyy urgent plsssssssssssssssssss follow the standard in the program
Need the program urgent very urgent please follow the standard in the program  Restaurant Order Management System (ROMS) Problem Case: Create a ROMS system, which is intended to take an order from the customer and charge
Standard JDK Tools
Standard JDK Tools Basic Tools Tool Name Brief Description javac  This is the core of java, the compiler for the Java... applications that use OMG-standard IDL and CORBA/IIOP. Tool Name 
 

 

 

DMCA.com