Sie sind auf Seite 1von 5

MSE108L

ORO, Andrea Beatrice S.

MSE-2
Exercise 1
Standard Deviation
In statistics and probability theory, standard deviation (represented by
the symbol sigma, ) shows how much variation or dispersion exists
from the average (mean), or expected value. A low standard
deviation indicates that the data points tend to be very close to the
mean; high standard deviation indicates that the data points are
spread out over a large range of values.
The standard deviation of a random variable, statistical
population, data set, or probability distribution is the square root of its
variance. It is algebraically simpler though practically less robust than
the average absolute deviation. A useful property of standard
deviation is that, unlike variance, it is expressed in the same units as
the data. Note, however, that for measurements with percentage as
unit, the standard deviation will have percentage points as unit.
In addition to expressing the variability of a population, standard
deviation is commonly used to measure confidence in statistical
conclusions. For example, the margin of error in polling data is
determined by calculating the expected standard deviation in the
results if the same poll were to be conducted multiple times. The
reported margin of error is typically about twice the standard
deviation - the radius of a 95 percent confidence interval. In science,
researchers commonly report the standard deviation of experimental
data, and only effects that fall far outside the range of standard
deviation are considered statistically significant normal random error
or variation in the measurements is in this way distinguished from
causal variation. Standard deviation is also important in finance,
where the standard deviation on the rate of return on an investment
is a measure of the volatility of the investment.
When only a sample of data from a population is available, the
standard deviation of the population can be estimated by a modified
quantity called the "sample standard deviation". When the sample is
the entire population, its unmodified standard deviation is called the
"population standard deviation".
Code:

package exercisee1;

import javax.swing.JOptionPane;
public class Exercisee1 {

public static void main(String[] args) {


String x = JOptionPane.showInputDialog("Enter
number of samples:");
int sample = Integer.parseInt(x);
double[]s = new double[sample];
double sum = 0;
double var;

for(int i=0; i < sample; i++)


{
String y =
JOptionPane.showInputDialog("Enter number:"+i);
s[i] = Double.parseDouble(y);
sum += s[i];
}
double var1 = 0;
double StandardDev;
double average = sum/sample;
for(int i=0; i<sample;i++){
var1 += (s[i]-average)*(s[i]-average);
}
var = var1/sample;
StandardDev = Math.sqrt(var);

JOptionPane.showMessageDialog(null,"The
Average is: "+average);
JOptionPane.showMessageDialog(null,"The
Standard Deviation is:
"+StandardDev,"AverageandStandardDeviation",J
OptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null,"The
Variance is: "+var);
}
}
Flowchart:

Start

Data in n
(number of
values)

String
counter =1

Program call, end


average

Data out,
sd

Math.pow(co SdMath.sqrt(
conut-avg2) dev)

Das könnte Ihnen auch gefallen