Robotics C++ Physics II AP Physics B Electronics Java Astronomy Other Courses Summer Session  

Statistics

 

 

 

 

 

Definitions

 

Statistics

 

In statistics we are concerned with drawing conclusions about a population based on data taken from a subset of the population.
 
Statistics can be applied to experimental data in at lest two ways. Firs we can test the consistency - accuracy - of the data. Second, the values of unknown parameters can be derived from experimental data.
 

Probability

 
The set of all possible outcomes of an experiment is called the sample space.  An event is defined as a subset of a sample space.
 
If an experiment can result in any one of N different equally likely outcomes, and if exactly n of these outcomes correspond to event A, then the probability oif event A is
 
P(A) = n/N

 

Probability Distribution

 
The function f(x) is a probability distribution of the random variable X if, for each possible outcome x
 
f(x) >= 0, the sum of all f(x) = 1 (area under the curve = 1), and P(X = x) = f(x). The latter means that the probability that X takes on the value x is the value of the function evaluated at x.
 

Mean

 
The mean of a random sample is defined as the average value (sum the values and divide by the number)
 

Standard Deviation

 
The square of the standard deviation of a random sample is found by taking the sum of the squares of the difference of the values from the mean and dividing the sum by n - 1 where n is the number of samples. The standard deviation is the square root of this number. The square is taken to eliminate the effects of negative numbers. In sum, it gives a measure of the deviation about the mean.
 
Linear Regression Example
Finding an estimated value given data points

 

Code (for curve y = 2*x, evaluated at x = 0.5)

 

import alpcentauri.*;

class LinearRegressionExample

{

  public static void main (String[]args)

  {

    double[] x = {1,2,3,4};

    double[] y = {2,4,6,8};

    LinearRegression LinReg = new LinearRegression();

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

      LinReg.add(x[i],y[i]);

    double slope = LinReg.getSlope();

    double intercept = LinReg.getIntercept();

    double correlationCoefficient = LinReg.getCorrelationCoefficient();

    EstimatedPolynomial estimation = LinReg.asEstimatedPolynomial();

    double value = estimation.value(0.5);

    double error = estimation.error(0.5);

    System.out.print("The estimate of the linear regression at 0.5 is: "+value);

  }

}

 

Output

 

 
Least Squares Fit with Polynomials Example