you can use matlab or C program to solve this problem. Given the data: Determine
ID: 3693735 • Letter: Y
Question
you can use matlab or C program to solve this problem.
Given the data: Determine (a) the mean, (b) median, (c) mode, (d) range, (e) standard deviation, (f) variance, and (g) coefficient of variation, (h) Construct a histogram. Use a range from 28 to 34 with increments of 0.4. Note: change your bins within the hist (data, bins) function from MATLAB. (i) Assuming that the distribution Ls normal, and that your estimate of the standard deviation is valid, compute the range (i.e., the lower and the upper values) that encompasses 68% of the readings from your histogram. Determine whether this is a valid estimate for the data in this problem.Explanation / Answer
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define MAX 100
void main()
{
float CV,x=0.0,y=0.0,a[MAX],b[MAX]={0},sum=0,sum1=0,variance,st_devi,t;
int n,i,j,mode,max,c=1,k=0;
clrscr();
printf("Enter the no.of elements ");
scanf("%d",&n);
printf("Enter the set of numbers ");
for(i=0;i<n;i++)
{
scanf("%f",&a[i]);
sum+=a[i];
}
x=sum/(float)n;
printf("Mean =%f",x);
for(i=0;i<n;i++)
{
sum1=sum1+pow((a[i]-x),2);
}
variance=sum1/(float)n;
st_devi=sqrt(variance);
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
if(n%2==0)
{
y=(a[n/2]+a[(n-1)/2])/2;
}
else
{
y=a[(n-1)/2];
}
printf(" Median =%f",y);
for(i=0;i<n-1;i++)
{
mode=0;
for(j=i+1;j<n;j++)
{
if(a[i]==a[j])
{
mode++;
}
}
if((mode>max) && (mode!=0))
{
k=0;
max=mode;
b[k]=a[i];
k++;
}
else if(mode==max)
{
b[k]=a[i];
k++;
}
}
for(i=0;i<n;i++)
{
if(a[i]==b[i])
c++;
}
if(c==n)
printf(" There is no mode");
else
{
printf(" Mode =");
for(i=0;i<k;i++)
printf("%f ",b[i]);
}
printf("Standard Deviation = % .2f ",st_devi);
printf("Variance = %. 2f ",variance);
CV=st_devi/x;
printf("Coefficient of variation = % .2f ]n",CV);
printf("Histogram.........");
for(i=0;i<n;i++)
{
printf(" %3d|",i);
for(j=0;j<a[i];++j)
printf("#");
}
getch();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.