adds

To find the mean & variance using c++:
THEORY:

 For a data set, the terms arithmetic mean, mathematical expectation, and sometimes average are used synonymously to refer to a central value of a discrete set of numbers.
If x1,x2,x3…….xn are a set of data, the mean can be calculated as
Xmean=(x1+x2+………….+xn)/n
            Variance is the expectation of the squared deviation of a random variable from its mean, & it informally measures how far a set of (random) numbers are spread out from their mean. The variance is the square of standard deviation.
Var(X)=(1/N)*{∑i=1  (xi-xmean)2 }
Standard Deviation:
Standard deviation is a measure of the dispersion of a set of data from its mean. It is defined as the square root of its variance.
CODING:
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
float x[10];
int i,n;
float avg,var,sum=0,sum1=0;
clrscr();
cout<<"N= \n";
cin>>n;
cout<<"list of number = \n";
for(i=0;i<n;i++)
{
cin>>x[i];
}
for(i=0;i<n;i++)
{
sum=sum+x[i];
}
avg=sum/n;
for(i=0;i<n;i++)
{
sum1=sum1+pow(x[i]-avg,2);
}
var=sum1/n;
cout<<"average = \n"<<avg<<endl;
cout<<"varience = \n"<<var;
getch();
}
OUTPUT:


Model syllabus (+3)Downoad

List of all practicals:   Download

Get all Books:  Download
Physics Notes: CLICK

IIT-JAM             JEST                GATE               NET
                                                           
  • How to Prepare for IIT-JAM  ⇠ ⇠ Click Here
Get everything about your B.Sc (+3) Physics Practical⇠ ⇠Click
"“Creativity is the residue of time wasted.”"  Albert Einstein

Post a Comment

Previous Post Next Post