




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Several c++ programs to simulate and calculate the probability distribution functions (pdf) and cumulative distribution functions (cdf) for different probability distributions, including uniform, exponential, and poisson distributions. The user is prompted to input parameters such as the number of trials, probability values, and distribution types. The programs then output the pdf and cdf values for the given distribution.
Typology: Thesis
1 / 137
This page cannot be seen from the preview
Don't miss anything!





























































































Paper I
Section I
Computer Simulation & Modeling
Mahatma Gandhi Mission’s College of Computer Science & Information Technology At junction NH4 Sion-Panvel Expressway, Kamothe, Navi Mumbai-410 209.
M.Sc.(IT)PART-I
This is to certify that Mr. kirtikumar dilip giripunje of M.Sc.(IT)Part-I. Roll No. 17 has
completed the course of necessary practical’s in
the subject of Computer Simulation & Modeling
under my supervision during the academic year
2010-2011.
Sr.N o
Date Topic^ Page No.
Sign
1. Single Sever Queuing **Model
#include<stdio.h> #include<math.h> #include<stdlib.h> #include<time.h> void main() { clrscr(); int i,j; //with this statement diff random no will be generated every time time_t t; srand((unsigned) time(&t));
//inter arrival variables int arrtime[20],arrrandom[20]; float arrprob[20],cdf=0,arrcdf[20];
//service time variables int sertime[20],serrandom[20]; float serprob[]={0,0.05,0.1,0.2,0.3,0.25,0.1};// probability for service table float sercdf[20];
//simulation table variables int rnoarr[20];
int rnoser[20]; int arrivaltime[20],clocktime[20]; int servicetime[20],servicein[20],serviceout[20]; int waittime[20],idletime[20]; float wait=0,idle=0,service=0,timespent=0; //input arrival time table for(i=1;i<=8;i++) { arrtime[i]=i; } //prob for inter arrival table for(i=1;i<=8;i++) { arrprob[i]=0.125; } for(i=1;i<=8;i++) { cdf=cdf+arrprob[i]; arrcdf[i]=cdf; } for(i=1;i<=8;i++) { arrrandom[i]=arrcdf[i]*1000;
// input service time table
for(i=1;i<=6;i++) { sertime[i]=i; } cdf=0; for(i=1;i<=6;i++) { cdf=cdf+serprob[i]; sercdf[i]=cdf; } for(i=1;i<=6;i++) { serrandom[i]=sercdf[i]*100; } //display service time table cout<<"-------------------------------------------------------- --------------"<<endl; cout<<"Input service time table"<<endl;
cout<<"service time:\tprob:\tcdf:\trandom no.allocation:"<<endl; for(i=1;i<=6;i++) { cout<<sertime[i]<<"\t\t"<<serprob [i]<<"\t"<<sercdf[i]<<"\t\t";
if(i==1) { cout<<"01-"<<serrandom[i]<<endl; } else if(i==6) { cout<<serrandom[i-1]+1<<"-00"<<endl; } else { cout<<serrandom[i-1]+1<<"-"<<serrandom [i]<<endl; } } cout<<"-------------------------------------------------------- --------------"<<endl; ///////////////////////////////////////////////////// //simulation table
arrivaltime[1]=0; //classifying service random nos for(i=1;i<=20;i++) { for(j=1;j<=6;j++) { if(rnoser[i]<=serrandom[j]) { servicetime[i]=sertime[j]; break; }
} } //calculating clock time cdf=0; for(i=1;i<=20;i++) { cdf=cdf+arrivaltime[i]; clocktime[i]=cdf; }
//calculating service in and out for(i=1;i<=20;i++)
if(i==1) { servicein[i]=clocktime[i]; serviceout[i]=servicetime[i]; } else { if(clocktime[i] > serviceout[i-1]) { servicein[i]=clocktime[i]; serviceout[i]=servicein[i]+servicetime [i]; } else { servicein[i]=serviceout[i-1]; serviceout[i]=servicein[i]+servicetime [i]; } } }
//calculating clock time for(i=1;i<=20;i++)
for(i=1;i<=20;i++) { idle=idle+idletime[i]; wait=wait+waittime[i]; service=service+servicetime[i]; } idle=idle/20; wait=wait/20; service=service/20; timespent=wait+service;
cout<<endl<<"Average waiting time is: "<<wait<<"mins"<<endl; cout<<"Average service time is : "<<service<<"mins"<<endl; cout<<"Probability of idle server is: "<<idle<<endl; cout<<"Average time the customer spends in the system: "<<timespent<<"mins"<<endl; getch(); }
Output:-
Practical No. 2
Aim: To Implement a two sever system using EXCEL / C
Code:
#include<iostream.h>
#include <stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<math.h>
#define SIZE 15
void main()
{
//arrival time cout<<"Enter total time between arrivals(e.g 3) \n"; cin>>atime; cout<<"Enter "<<atime<<" time between arrivals(e.g 1,1.5.....) \n";
for(i=0;i<atime;i++) { cin>>aatime[i]; } cout<<"Enter probability for "<<atime<<" arrivals \n"; for(i=0;i<atime;i++) { cin>>aprob[i]; } acdf[-1]=0.0; for(j=0;j<atime;j++) { acdf[j]=acdf[j-1]+aprob[j]; } for(j=0;j<atime;j++) {
arand[j]=acdf[j]*1000; }
//able service(); cout<<"Enter total sevice time for able(e.g 3) \n"; cin>>astime; cout<<"Enter "<<astime<<" service time for able(e.g 1,1.5.....) \n"; for(i=0;i<astime;i++) { cin>>asstime[i]; } cout<<"Enter probability for "<<astime<<" servises by able \n";
for(i=0;i<astime;i++) { cin>>asprob[i]; } ascdf[-1]=0; for(j=0;j<astime;j++) { ascdf[j]=ascdf[j-1]+asprob[j]; }