0% found this document useful (0 votes)
28 views4 pages

Estimation of Population Meanwithout Replacement

This document contains code to estimate population mean, total, confidence limits, and variance using simple random sampling without replacement. It prompts the user to input population and sample sizes, then temperature values from two locations. It calculates means, variances, and other statistics using the input data.

Uploaded by

Sanyam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views4 pages

Estimation of Population Meanwithout Replacement

This document contains code to estimate population mean, total, confidence limits, and variance using simple random sampling without replacement. It prompts the user to input population and sample sizes, then temperature values from two locations. It calculates means, variances, and other statistics using the input data.

Uploaded by

Sanyam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

//Estimation of population mean,total,confidence limits and variance

and estimation under simple random sampling without replacement:


#include<stdio.h>

#include<math.h>

void main()

int i,n,n1,n2,N2,N1,N,x[20],y[20];

float
sum=0,sum1=0,sum2=0,sum3=0,sum4=0,sum5=0,meanc,meand,tmean,a,b,varst,s_sqrd,s_sqrc,d1,d2,s_sqrwor
,varwor;

printf("Enter the population size:");

scanf("%d",&N);

printf("Enter the population size for Delhi:");

scanf("%d",&N1);

printf ("Enter the population size for Chandigarh:");

scanf("%d",&N2);

printf("Enter the sample size:");

scanf("%d",&n);

printf("Enter the sample size for Delhi:");

scanf("%d",&n1);

printf ("Enter the sample size for Chandigarh:");

scanf("%d",&n2);

printf("Enter the temperature values for Delhi:");

for(i=0;i<N1;i++)

scanf("%d",&x[i]);

sum+=x[i];

meand=sum/N1;

printf("Enter the temperature values for Chandigarh:");

for(i=0;i<N2;i++)

scanf("%d",&y[i]);
sum1+=y[i];

meanc=sum1/N2;

a=N1-1;

b=N2-1;

for(i=0;i<N1;i++)

sum2+=(x[i]-meand)*(x[i]-meand);

s_sqrd=sum2/a;

for(i=0;i<N2;i++)

sum3+=(y[i]-meanc)*(y[i]-meanc);

s_sqrc=sum3/b;

d1=(N1*(N1-n1)*s_sqrd)/n1;

d2=(N2*(N2-n2)*s_sqrc)/n2;

varst=(d1+d2)/(N*N);

printf("The variance for stratified random sampling is: %f\n",varst);

tmean=(sum+sum1)/N;

for(i=0;i<N1;i++)

sum4+=(x[i]-tmean)*(x[i]-tmean);

for(i=0;i<N2;i++)

sum5+=(y[i]-tmean)*(y[i]-tmean);

s_sqrwor=(sum4+sum5)/(N-1);

varwor=((N-n)*s_sqrwor)/(n*N);

printf("The variance for simple random sampling without replacement is: %f",varwor);

}
Output:

You might also like