C++ Program to Simulate Probability Distributions, Thesis of Mathematical Modeling and Simulation

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

2017/2018

Uploaded on 04/05/2018

roshan-koju-1
roshan-koju-1 🇳🇵

4.6

(8)

9 documents

1 / 137

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Paper I
Section I
Computer Simulation & Modeling
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download C++ Program to Simulate Probability Distributions and more Thesis Mathematical Modeling and Simulation in PDF only on Docsity!

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

CERTIFICATE

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

  1. Two Sever Queuing Model
  2. Newspaper Seller Problem
  3. Discrete Distribution**
    1. Bernoulli Distribution
    2. Binominal Distribution
    3. Geometric Distribution
    4. **Poisson Distribution
  4. Continuous Distribution**
    1. Uniform Distribution
  1. Exponential Distribution
  2. (^) Gamma Distribution
  3. Weibull Distribution
  4. Normal Distribution
  5. Triangular Distribution
  6. **Erlang Distribution
  7. Generate Random Number**
  8. Linear Congruetial Method
  9. Multi Congruetial Method
  10. (^) Inverse Transform Tech.
  11. **Accept / Reject Tech.
  12. Random Number Test**

#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]; }