0% found this document useful (0 votes)
12 views

True Int Input: # Leer Max

This document defines a Generator class and describes a simulation to generate random numbers and calculate the time of an event using an exponential distribution. It initializes a Generator object, gets user input for the number of simulations and value of μ, runs the simulation that generates random numbers, calculates the time of each event, and prints the results.

Uploaded by

dreux
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

True Int Input: # Leer Max

This document defines a Generator class and describes a simulation to generate random numbers and calculate the time of an event using an exponential distribution. It initializes a Generator object, gets user input for the number of simulations and value of μ, runs the simulation that generates random numbers, calculates the time of each event, and prints the results.

Uploaded by

dreux
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1 from generator import Generator

2
3 from random import random, seed,randint
4 from decimal import *
5 from math import exp
6
7
8 def main():
9
10 gen = Generator()
11 # LEER MAX
12 while True:
13 gen.NUM_SIMULATION = int(
14 input("Introduzca el nùmero de ensayos: "))
15 if gen.NUM_SIMULATION > 0 or gen.NUM_SIMULATION <= gen.NORM - 0:
16 break
17 pass
18 pass # END WHILE GEN.NUM_SIMULATION
19 M = 0
20 while True:
21 M = float(input("Introduzca el valor de µ: "))
22 if M >=0 :
23 break
24 pass
25 pass
26
27 gen.initGenerator(gen.NUM_SIMULATION)
28
29 PROB = 0
30 SEM = randint(100,gen.NUM_SIMULATION)
31 getcontext().prec = 8
32 SUM = 0
33 rnd = []
34 for x in range(1,gen.NUM_SIMULATION+1):
35 SEM = gen.mixed_rand(SEM)
36 RND = Decimal(SEM / gen.NORM)
37 PROB = exp(-M)
38 SUM = PROB
39 i = 0
40 while RND >= SUM :
41 i+=1
42 PROB = M * PROB/i
43 SUM += PROB
44 pass
45 rnd.append(i)
46 # print("El {} tiempo de espera es: {}".format(x,i))
47 pass
48 gen.print_in_columns(rnd,25)
49 pass
50
51 if __name__ == '__main__':
52 main()

You might also like