Skip to main content

Posts

Coding for distributions (geometric/weibull)

#include #include #include long fact(int n) { if(n<=0) return 1; else return n*fact(n-1); } double geomean(int x,double p,double q) { if(x>0) return pow(q,x-1)*p; else return 0; } double weibpdf(int x, double v, double a, double b) { if(x =0) return fact(n)/(fact(x)*fact(n-x))*pow(p,x)*pow(q,n-x); else return 0; } int main() { int ch; double p,q,v,a,b; int x,n; clrscr(); do { printf("\nExit."); printf("\nGeometric Mean."); printf("\nWeibull Distribution."); printf("\nPoisson Distribution."); printf("\nBinomial Distribution."); printf("\nEnter your choice => "); scanf("%d",&ch); if(ch==1) { printf("\n\tEnter the value of x,p,q => "); scanf("%d%lf%lf",&x,&p,&q); prin

Coding for M/M/1 server

#include #include void main() { int i,a,d,arrival[11],clock=0,inter[]={2,3,1,4,1,6,1,1,5,2,1},service[]= {2,5,4,3,3,5,6,6,6,3,2}; int wait[11],q=0,sum=0,avg,server; arrival[0]=clock+inter[0]; d=clock+service[0]; server=1; a=arrival[0]; wait[0]=0; for(i=0;i<11;i++) { arrival[i]=arrival[i-1]+inter[i]; } printf("clock=%d (A=%d)(D=%d)(W=%d)",clock,a,d,wait[0]) ; i=1; while(clock<30) { if(a d) {wait[i]=0; printf("clock=%d (A=%d)(D=%d)(W=%d)",clock,a,d,wait[1]) ; i++; } else if(d a) { wait[i]=d-a; } printf("\nclock = %d (A,%d) (D,%d) (w,%d)",clock,a,d,wait[i]); } else { wait[i]=0; printf("clock=%d (A=%d)(D=%d)(W=%d)",clock,a,d,wait[i]) ; server=0; } } else { clock=0; a=arrival[i]; d=clock+service[i-q]; if(a { wait[i]=d-a; } else { wait[i]=0; i++; printf("clock=%d (A=%d)(D=%d)(W=%d)",clock,a,d,wait[i]) ; } } else { clock=0; a=arrival[i]; d=clock+service[i]; wait[i]=d-a; i++; printf(

Simulation & Modeling (ASSIGNMENTS) [LAB + Theory}

Roll No. Assignments 2032,4501 Music Shop Inventory Problem,Simulation of computer system 4502,4506 Web Simulation, 4507,4568,4538 Food bazaar, Simulation of Queuing System and its applications e.g. Food Bazaar 4508,4536,4546 Simulating a banquet hall,Input Output modeling for simulation 4509 Random Number generation for simulation 4510,4525,4520 Telephone Simulation System, Application of Simulation for solving network flow problems 4511,4543 Simulating Car Parking 4513,4533,4531 Monte-carlo Simulation 4514 Simulating grocery Shop 4516,4535,4551/08 Traffic Simulation, Simulation of websites to improve traffic for a website 4515,4528,4529 Understanding GPSS 4518,4554,4566 Gaming Simulation 4519,4524 Conducing web simulation on e-commerce portals 4530,4551,4556 Simulating Delhi Metro, Understanding Object oriented simulation 4534,4557

Simulation & Modeling Software

We can understand computer simulation language as the language which describes operation of a simulation on a computer. It can be broadly categorized in following two categories: 1. continuous 2. Discrete event Many lnguages have a graphical interface and are capable of performing simple statistical analysis of the results. While using discrete-event languages we can easily generate pseudo-random numbers and determine variables using different probability distributions. Some of the Discrete event and continuous language packages have been listed below: AutoMod eM-Plant Arena ExtendSim simulation environment for discrete event, continuous, discrete-rate and agent-based simulation.[1] GASP GPSS Plant Simulation Simio software for discrete event, continuous, and agent-based simulation.[2] SimPLE++ SimPy, an open-source package based on Python SIMSCRIPT II.5, a well established commercial compiler Simula Java Modelling Tools, an open-source package with grap

Simulation Software

Discuss the following periods in simulation history? a. The period of Search: Simulation was conducted in FORTRAN and other gernal purpose languages. No specific simulation specific routines. Much effort was on expanding searcn for unifying concepts and the development of reusable routines to facilitate simulation(1955-60) b Advent : It is the period of forerunners of SPL we use today(1961-65) GPSS developd by Geoffery Gordon at IBM and appeared in 1961. General Purpose Simulation system was developed for quick simulation of communication and computer system. It is a block disgram based representation (similar to process flow diagram) and suited for queuing models. Phillip J Kiviat developed GASP (General Activity based simulation program). Originally it was based on GPL ALGOL but later based on FORTRAN. other SPL developed are SIhMULA(extension of ALGOL) c. The Formative period (from 1966-1970) Concepts were reviewed adn refined to promote more consistent re

Linear Congruential method ( Random Number generation )

#include #include #define true 1 #define false 0 void main() { int x[30]; int flag=true,i,a,c,m,x0; float r[30]; printf("\n Enter a,c,m,x0"); scanf("%d%d%d%d",&a,&c,&m,&x0); x[0]=x0; i=1; while(flag==true) { x[i]=(a*x[i-1]+c)%m; r[i]=x[i]/(float)m; if(x[i]==x[0])//Now onwards series will repeat flag=false; i++; printf("x[i]=%d\n",x[i-1]); } getch(); } omprakash sharma 4552/09

Weibull Distribution Implementation (Simulation and Modeling)

#include #include #include double f(int x, double v, double a, double b) { if(x< v) return 0; else { return b/a*(pow((x-v)/a,b-1))*exp(-pow((x-v)/a,b)); } } double F(int x, double v, double a, double b) { if(x return 0; else { return (1 - exp(-pow((x-v)/a,b))); } } int main() { int x; double v,a,b; clrscr(); printf("enter d value of x, location, shape & scale: "); scanf(" %d %lf %lf %lf",&x, &v, &b, &a); printf(" f(%d) = %f",x,f(x,v,a,b)); printf(" F(%d) = %f",x,F(x,v,a,b)); getch(); return 0; } Pankaj kumar mca4506/09