eventsims 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c14a98f8416741099ed89150135a0fcb2875cb1a
4
- data.tar.gz: edb09fc49abceb6650406dbb0cbf1c23d02bbbf8
3
+ metadata.gz: 370638fef8adbe673a198d43a1a1d3b20aded8e2
4
+ data.tar.gz: 42eeacce80ec2af8803d424513ddd742de8ed42f
5
5
  SHA512:
6
- metadata.gz: 5b944852af53fccc3b5b1d70ee041a2dce356b9d63f25c1dc730e277e7e5480b3f0a31a10f03eda1bf3239e4e5631d749265aed1b995e371670a20df170b4616
7
- data.tar.gz: 1c2ef1840388301c1795bc43eab208c40713ae8398e12bee73cc600a77d418006b2933e7554812a83fa8ab7f9c4c9871be02cc314b1ae00c5868515f8f0f730d
6
+ metadata.gz: daa9a3896a416c6a45765027c3bab9401d3842754c8b28f1ce88ee4bd08154e939bd352c5fe0147be69bcf56054a79031d80dbfb3a29155a896b077030c0e649
7
+ data.tar.gz: 5b196815dec082248f99d2b86a3bba3361cbc2fb0acc76eb3de855dfbf53afb29384371a49838cb106c41a424b9db0ca1454ad97412dced222828617b19547d7
@@ -0,0 +1,21 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ eventsims (0.0.2)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.4.2)
10
+
11
+ PLATFORMS
12
+ ruby
13
+ x86-mingw32
14
+
15
+ DEPENDENCIES
16
+ bundler (~> 1.10)
17
+ eventsims!
18
+ rake (~> 10.0)
19
+
20
+ BUNDLED WITH
21
+ 1.10.6
data/README.md CHANGED
@@ -1,22 +1,41 @@
1
1
  # Eventsims
2
2
 
3
3
  ## Description
4
+ Eventsims is a Ruby package that uses various useful tools in simulating discrete system events based on outcome and probabilities easily.
4
5
 
5
- Eventsims contains various useful tools to makes discrete event easy to simulate.
6
+ ## Requirements
7
+ * Any version of Ruby
6
8
 
9
+ ## Installation
10
+ Add this line to your application's Gemfile:
7
11
 
8
- # MODULE NAME --> Eventsims
12
+ ```ruby
13
+ gem 'eventsims'
14
+ ```
9
15
 
16
+ And then execute:
10
17
 
11
- ## Module Classes
18
+ $ bundle
12
19
 
20
+ Or install it yourself as:
13
21
 
14
- ### Calculate
22
+ $ gem install eventsims
15
23
 
16
- **Calculate** takes two list Arrays (outcome, cummulative probability) as arguments and an optional integer value `(steps)` for simplifying and calculating several data.
24
+
25
+ ## Module name --> Eventsims
26
+ It contains four main classes and two methods.
27
+
28
+ ## Module Classes
29
+
30
+ ### Calculate
31
+ **Calculate** has six methods for calculating/generating ``probability``, ``estimated variance``, ``estimated mean``, ``estimated standard deviation``, ``expectation value`` and ``discreteEmp``.
32
+
33
+ Eventsims' "`Calculate` class" takes `two arguments`: ``outcome`` and ``cummulative probability`` or a third optional argument which is `amount of times to be generated` (``steps``).
17
34
 
18
35
  #### Methods
19
36
 
37
+ Calculate methods are:
38
+
20
39
  * prob() ----> To calculate the probability based on the given outcome list(second argument of the **Calculate** instance).
21
40
  * discreteemp() ----> To generate a random outcome depending on its probability of occurrence.
22
41
  * expectval() ----> To generate an expectation value i.e. the mean of the outcome depending on its probability
@@ -24,162 +43,704 @@ Eventsims contains various useful tools to makes discrete event easy to simulate
24
43
  * estvar() ----> To calculate the estimated variance of the list data
25
44
  * eststddev ----> To calculate the estimated standard deviation of the list data
26
45
 
27
- #### Usage Example
28
46
 
29
- ```
47
+ #### Usage
48
+ You can use the Calculate class in the following way:
49
+
50
+ ##### Example 1
51
+
52
+ **Two arguments**
53
+
54
+ Usage: Calculate.new(**outcome list**, **cummulative probability list**)
55
+
56
+
57
+ ```ruby
30
58
  require "Eventsims"
31
59
 
32
- sample = Eventsims::Calculate.new([-1, 0, 3, 4], [0.1, 0.4, 0.7, 1], 10)
60
+ sample = Eventsims::Calculate.new(a, b)
61
+
62
+ a = [-1,0,3,4]
63
+ b = [0.1, 0.4, 0.7, 1]
64
+
65
+ puts "Probability: #{sample.prob()}"
66
+ puts "DiscreteEmp: #{sample.discreteemp()}"
67
+ puts "Expectation value: #{sample.expectval()}"
68
+ puts "Estimated Mean: #{sample.estmean()}"
69
+ puts "Estimated Variance: #{sample.estvar()}"
70
+ puts "Estimated Standard deviation: #{sample.eststddev()}"
71
+ ```
72
+
73
+ ##### Result 1
74
+
33
75
 
34
- puts "probability: #{sample.prob()}"
35
- puts "Arrival time: #{sample.discreteemp()}"
36
- puts "Estimated standard deviation: #{sample.eststddev()}"
37
- puts "Estimated mean: #{sample.estmean()}"
76
+ ```ruby
77
+ Probability: [0.1, 0.3, 0.3, 0.3]
78
+ DiscreteEmp: 3
79
+ Expectation value: 2.0
80
+ Estimated Mean: 2.0
81
+ Estimated Variance: 3.6
82
+ Estimated Standard deviation: 1.8974
38
83
  ```
39
- #### Result
84
+
85
+ ##### Example 2
86
+
87
+ **three arguments**
88
+
89
+ Usage: Calculate.new(**outcome list**, **cummulative probability list**, "`Optional: amount/steps`")
90
+
91
+ ```ruby
92
+ require "Eventsims"
93
+
94
+ a = [-1,0,3,4]
95
+ b = [0.1, 0.4, 0.7, 1]
96
+
97
+ sample = Eventsims::Calculate.new(a, b, 10)
98
+
99
+ puts "Probability: #{sample.prob() }"
100
+ puts "DiscreteEmp: #{sample.discreteemp() }"
101
+ puts "Expectation value: #{sample.expectval() }"
102
+ puts "Estimated Mean: #{sample.estmean() }"
103
+ puts "Estimated Variance: #{sample.estvar() }"
104
+ puts "Estimated Standard deviation: #{sample.eststddev() }"
40
105
  ```
41
- probability: [0.1, 0.3, 0.3, 0.3]
42
- Arrival time: [-1, 3, 0, 4, 0, -1, 3, 0, 0, 3]
43
- Estimated standard deviation: 6.0
44
- Estimated mean: 20.0
106
+
107
+ ##### Result 2
108
+
109
+ ```ruby
110
+ Probability: [0.1, 0.3, 0.3, 0.3]
111
+ DiscreteEmp: [3, 0, 4, 4, 4, 4, 3, 0, 0, 0]
112
+ Expectation value: 20.0
113
+ Estimated Mean: 20.0
114
+ Estimated Variance: 36.0
115
+ Estimated Standard deviation: 6.0
45
116
  ```
46
117
 
118
+
119
+ > **argument one** of the Calculate class should be the **outcome** list while **argument two** should be the **cummulative probability** list. **Argument three (steps)** is optional and only needed if any of the data is to be calculated after a certain number of times or to generate a list of discreteEmp values.
120
+
121
+ > If no optional argument is given (same as if an optional argument is set to 1), discreteemp will generate only one outcome but if more the optional argument is more than one e.g. 5, then *discreteemp* will generate a list containing several generated outcomes (5 items in a list in this case).
122
+
123
+
124
+
47
125
  ### Generate
48
126
 
49
- **Generate** that takes integer numbers as arguments *(from no argument to 5 arguments)* with optional arguments being "r" or "s". r for reverse sorted and s for ascending order sort. it's methods and uses are shown below.
127
+ **Generate** takes integer values as arguments (from `no arguments` up to and including `five arguments`) with optional `string` arguments being **"r"** or **"s"**. **r** for **reverse (descending order) ** sorting and **s** for **ascending order** sorting. It has five methods which can be called on its instance namely:
50
128
 
51
- * outcome() —-> generate outcomes based on the inputs supplied as arguments.
52
- * unique() —-> generate unique outcomes based on the inputs supplied as arguments. You can think of it as a set of the outcome() method result.
53
- * occur() —-> generate the number of times a unique item is found.
54
- * getprob() —-> generate the probability of the outcome with respect to the unique outcome.
55
- * getcum() —-> generate the cummulative probability of occurrence with respect to the unique outcome.
129
+ #### Methods
56
130
 
57
- #### Usage example
58
- ```
131
+ * outcome() ----> generate outcomes based on the inputs supplied as arguments.
132
+ * unique() ----> generate unique outcomes based on the inputs supplied as arguments. You can think of it as a *set* of the outcome() method result.
133
+ * occur() ----> generate the number of times a unique item is found.
134
+ * getprob() ----> generate the probability of the outcome with respect to the unique outcome.
135
+ * getcum() ----> generate the cummulative probability of occurrence with respect to the unique outcome.
136
+
137
+
138
+ #### Usage
139
+
140
+ You can use the Generate class in the following ways:
141
+
142
+ > The following examples will cover how arguments are used in the Generate class. In the examples, we assume that the class has been required first as
143
+
144
+ ```ruby
59
145
  require "Eventsims"
146
+ ```
60
147
 
61
- sample = Eventsims::Generate.new(2, 5, 7, "s")
62
148
 
63
- puts ("Outcome: #{sample.outcome()}")
64
- puts ("Unique Outcome: {sample.unique()}")
65
- puts ("Occurrence: #{sample.occur()}")
66
- puts ("Probability: #sample.getprob()}")
67
- puts ("Cummulative Probability: #{sample.getcum()}")
149
+ ##### Example 1a
150
+
151
+ **zero arguments**
152
+
153
+ Usage: Eventsims::Generate.new()
154
+
155
+ What this does is populate the outcome list with random values (between 0 and 10) the default amount of times (i.e. a random number between 2 and 20).
156
+
157
+ ```ruby
158
+ sample = Eventsims::Generate.new()
159
+
160
+ puts "Outcome: #{sample.outcome() }"
161
+ puts "Unique Outcome: #{sample.unique() }"
162
+ puts "Occurrence: #{sample.occur() }"
163
+ puts "Probability: #{sample.getprob() }"
164
+ puts "Cummulative Probability: #{sample.getcum() }"
165
+ ```
166
+
167
+ ##### Result 1a
68
168
 
169
+ ```ruby
170
+ Outcome: [10, 4, 0, 5, 5, 2, 8, 4]
171
+ Unique Outcome: [10, 4, 0, 5, 2, 8]
172
+ Occurrence: [1, 2, 1, 2, 1, 1]
173
+ Probability: [0.25, 0.5, 0.25, 0.5, 0.25, 0.25]
174
+ Cummulative Probability: [0.25, 0.75, 1.0, 1.5, 1.75, 1.0]
69
175
  ```
70
176
 
71
- #### Result
177
+ ##### Example 1b
178
+
179
+ **Optional string argument**
180
+
181
+ Usage: Eventsims::Generate.new('optional: **sort** ')
182
+
183
+ Adding an optional string argument *"r"* will *sort* the *outcome* in *descending* order whereas using the *"s"* string argument will *sort* the *outcome* in *ascending* order
184
+
185
+ ```ruby
186
+ sample = Eventsims::Generate.new("r")
187
+
188
+ puts "Outcome: #{sample.outcome() }"
189
+ puts "Unique Outcome: #{sample.unique() }"
190
+ puts "Occurrence: #{sample.occur() }"
191
+ puts "Probability: #{sample.getprob() }"
192
+ puts "Cummulative Probability: #{sample.getcum() }"
193
+ ```
194
+
195
+ ##### Result 1b
196
+ ```ruby
197
+ Outcome: [5, 3, 2, 2, 1]
198
+ Unique Outcome: [5, 3, 2, 1]
199
+ Occurrence: [1, 1, 2, 1]
200
+ Probability: [0.2, 0.2, 0.4, 0.2]
201
+ Cummulative Probability: [0.2, 0.4, 0.8, 1.0]
202
+ ```
203
+
204
+ ##### Example 2a
205
+
206
+ **one argument**
207
+
208
+ Usage: Eventsims::Generate.new(**amount**)
209
+
210
+ What this does is populate the outcome list with random values (between 0 and 10) the amount of times specified in the argument. For example if 10 was specified in the argument, it will populate the outcome list with values ten times
211
+
212
+ ```ruby
213
+ sample = Eventsims::Generate.new(8)
214
+
215
+ puts "Outcome: #{sample.outcome() } "
216
+ puts "Unique Outcome: #{sample.unique() } "
217
+ puts "Occurrence: #{sample.occur() } "
218
+ puts "Probability: #{sample.getprob() } "
219
+ puts "Cummulative Probability: #{sample.getcum() } "
220
+ ```
221
+
222
+ ##### Result 2a
223
+ ```ruby
224
+ Outcome: [8, 4, 8, 1, 2, 9, 2, 9]
225
+ Unique Outcome: [8, 4, 1, 2, 9]
226
+ Occurrence: [2, 1, 1, 2, 2]
227
+ Probability: [0.25, 0.125, 0.125, 0.25, 0.25]
228
+ Cummulative Probability: [0.25, 0.375, 0.5, 0.75, 1.0
229
+ ```
230
+
231
+ ##### Example 2b
232
+
233
+ **Optional string argument**
234
+
235
+ Usage: Eventsims::Generate.new(**amount**, 'optional: **sort**')
236
+
237
+ Adding an optional string argument *"r"* will *sort* the *outcome* in *descending* order whereas using the *"s"* string argument will *sort* the *outcome* in *ascending* order
238
+
239
+ ```ruby
240
+ sample = Eventsims::Generate.new(10,"s")
241
+
242
+ puts "Outcome: #{sample.outcome() } "
243
+ puts "Unique Outcome: #{sample.unique() } "
244
+ puts "Occurrence: #{sample.occur() } "
245
+ puts "Probability: #{sample.getprob() } "
246
+ puts "Cummulative Probability: #{sample.getcum() } "
247
+
248
+ ```
249
+
250
+ ##### Result 2b
251
+ ```ruby
252
+ Outcome: [0, 1, 1, 1, 3, 4, 7, 7, 9, 10]
253
+ Unique Outcome: [0, 1, 3, 4, 7, 9, 10]
254
+ Occurrence: [1, 3, 1, 1, 2, 1, 1]
255
+ Probability: [0.1, 0.3, 0.1, 0.1, 0.2, 0.1, 0.1]
256
+ Cummulative Probability: [0.1, 0.4, 0.5, 0.6, 0.8, 0.9, 1.0]
257
+ ```
258
+
259
+ ##### Example 3a
260
+
261
+ **two arguments**
262
+
263
+ Usage: Eventsims::Generate.new(**start**, **stop**)
264
+
265
+ What this does is populate the outcome list with values (between argument one and argument two) the default amount of times (i.e. a random number between 2 and 20).
266
+
267
+ ```ruby
268
+ sample = Eventsims::Generate.new(3, 7)
269
+
270
+ puts "Outcome: #{sample.outcome() } "
271
+ puts "Unique Outcome: #{sample.unique() } "
272
+ puts "Occurrence: #{sample.occur() } "
273
+ puts "Probability: #{sample.getprob() } "
274
+ puts "Cummulative Probability: #{sample.getcum() } "
275
+
276
+ ```
277
+ ##### Result 3a
278
+ ```ruby
279
+ Outcome: [4, 7, 7, 4, 3, 3, 4, 4]
280
+ Unique Outcome: [4, 7, 3]
281
+ Occurrence: [4, 2, 2]
282
+ Probability: [0.5, 0.25, 0.25]
283
+ Cummulative Probability: [0.5, 0.75, 1.0]
284
+ ```
285
+
286
+
287
+ ##### Example 3b
288
+
289
+ **Optional string argument**
290
+
291
+ Usage: Eventsims::Generate.new(**start**, **stop**, 'optional: **sort** ')
292
+
293
+ Adding an optional string argument *"r"* will *sort* the *outcome* in *descending* order whereas using the *"s"* string argument will *sort* the *outcome* in *ascending* order
294
+
295
+ ```ruby
296
+ sample = Eventsims::Generate.new(2, 6, "r")
297
+
298
+ puts "Outcome: #{sample.outcome() } "
299
+ puts "Unique Outcome: #{sample.unique() } "
300
+ puts "Occurrence: #{sample.occur() } "
301
+ puts "Probability: #{sample.getprob() } "
302
+ puts "Cummulative Probability: #{sample.getcum() } "
303
+
304
+ ```
305
+
306
+ ##### Result 3b
307
+
308
+ ```ruby
309
+ Outcome: [6, 5, 5, 5, 4, 4, 4, 4, 2, 2]
310
+ Unique Outcome: [6, 5, 4, 2]
311
+ Occurrence: [1, 3, 4, 2]
312
+ Probability: [0.1, 0.3, 0.4, 0.2]
313
+ Cummulative Probability: [0.1, 0.4, 0.8, 1.0]
314
+ ```
315
+
316
+ ##### Example 4a
317
+
318
+ **three arguments**
319
+
320
+ Usage: Eventsims::Generate.new(**start**, **stop**, **amount**)
321
+
322
+ What this does is populate the outcome list with values (between argument one and argument two) the amount of times supplied in argument three. i.e. if 4 was supplied as the third argument, there will be four values in the outcome list.
323
+
324
+ ```ruby
325
+ sample = Eventsims::Generate.new(2, 5, 7)
326
+
327
+ puts "Outcome: #{sample.outcome() } "
328
+ puts "Unique Outcome: #{sample.unique() } "
329
+ puts "Occurrence: #{sample.occur() } "
330
+ puts "Probability: #{sample.getprob() } "
331
+ puts "Cummulative Probability: #{sample.getcum() } "
332
+
333
+ ```
334
+ ##### Result 4a
335
+
336
+ ```ruby
337
+ Outcome: [5, 5, 4, 4, 4, 2, 3]
338
+ Unique Outcome: [5, 4, 2, 3]
339
+ Occurrence: [2, 3, 1, 1]
340
+ Probability: [0.2857, 0.4286, 0.1429, 0.1429]
341
+ Cummulative Probability: [0.2857, 0.7143, 0.8572, 1.0]
342
+ ```
343
+
344
+ ##### Example 4b
345
+
346
+ **Optional string argument**
347
+
348
+ Usage: Eventsims::Generate.new(**start**, **stop**, **amount**, 'optional: **sort** ')
349
+
350
+ Adding an optional string argument *"r"* will *sort* the *outcome* in *descending* order whereas using the *"s"* string argument will *sort* the *outcome* in *ascending* order
351
+
352
+ ```ruby
353
+ sample = Eventsims::Generate.new(2, 5, 7, "s")
354
+
355
+ puts "Outcome: #{sample.outcome() } "
356
+ puts "Unique Outcome: #{sample.unique() } "
357
+ puts "Occurrence: #{sample.occur() } "
358
+ puts "Probability: #{sample.getprob() } "
359
+ puts "Cummulative Probability: #{sample.getcum() } "
72
360
 
73
361
  ```
362
+
363
+ ##### Result 4b
364
+
365
+ ```ruby
74
366
  Outcome: [2, 3, 3, 4, 4, 5, 5]
75
367
  Unique Outcome: [2, 3, 4, 5]
76
368
  Occurrence: [1, 2, 2, 2]
77
369
  Probability: [0.1429, 0.2857, 0.2857, 0.2857]
78
370
  Cummulative Probability: [0.1429, 0.4286, 0.7143, 1.0]
79
371
  ```
80
- ### Randomsim and Simulate
81
372
 
82
- contains classes for generating and estimating events that happens in a workplace scenario. Simulating events using methods some methods covered below
83
373
 
374
+ ##### Example 5a
84
375
 
85
- #### What they do
86
- * Randomsim which generates random values to populate the inter-arrival and service time ad then calculates the rest of the values (accepts 0 - 3 arguments)
376
+ **four arguments**
87
377
 
88
- * Simulate, a more flexible class that allows you to input your own inter-arrival time and service time as a list Array (takes 1-2 arguments [inter-arrival, service] time). If only one list Array is passed to the argument. it becomes the inter-arrival time and a random list between 1 and 10 will be generated for service time
378
+ Usage: Eventsims::Generate.new(**start**, **stop**, **step**, **amount**)
89
379
 
380
+ What this does is populate the outcome list with values (between argument one and argument two) in steps of argument three value the amount of times in argument four's value.
90
381
 
91
- #### Methods
382
+ ```ruby
383
+ sample = Eventsims::Generate.new(2, 20, 3, 10)
384
+
385
+ puts "Outcome: #{sample.outcome() } "
386
+ puts "Unique Outcome: #{sample.unique() } "
387
+ puts "Occurrence: #{sample.occur() } "
388
+ puts "Probability: #{sample.getprob() } "
389
+ puts "Cummulative Probability: #{sample.getcum() } "
390
+
391
+ ```
392
+
393
+ ##### Result 5a
394
+
395
+ ```ruby
396
+ Outcome: [20, 8, 11, 5, 11, 17, 20, 17, 14, 20]
397
+ Unique Outcome: [20, 8, 11, 5, 17, 14]
398
+ Occurrence: [3, 1, 2, 1, 2, 1]
399
+ Probability: [0.3, 0.1, 0.2, 0.1, 0.2, 0.1]
400
+ Cummulative Probability: [0.3, 0.4, 0.6, 0.7, 0.9, 1.0]
401
+ ```
402
+
403
+
404
+ ##### Example 5b
405
+
406
+ **Optional string argument**
407
+
408
+ Usage: Eventsims::Generate.new(**start**, **stop**, **step**, **amount**, 'optional: **sort** ')
409
+
410
+ Adding an optional string argument *"r"* will *sort* the *outcome* in *descending* order whereas using the *"s"* string argument will *sort* the *outcome* in *ascending* order
92
411
 
93
- * intarrival() —-> Displays the inter-arrival time in a list.
94
- * arrival() —-> Displays the arrival time in a list.
95
- * service() —-> Displays the service time in a list.
96
- * servbegin() —-> Display the time service begins in a list.
97
- * servend() —-> Display the time service ends in a list.
98
- * queuewait() —-> Display the time the customer spent waiting in a list.
99
- * custspend() —-> Display the time the customer spent in the system i.e. total time of service.
100
- * idle() —> Display the idle time of the server (cashier).
412
+ ```ruby
413
+ sample = Eventsims::Generate.new(2, 20, 3, 10, "r")
414
+
415
+ puts "Outcome: #{sample.outcome() } "
416
+ puts "Unique Outcome: #{sample.unique() } "
417
+ puts "Occurrence: #{sample.occur() } "
418
+ puts "Probability: #{sample.getprob() } "
419
+ puts "Cummulative Probability: #{sample.getcum() } "
101
420
 
421
+ ```
102
422
 
423
+ ##### Result 5b
103
424
 
104
- #### Usage Example
425
+ ```ruby
426
+ Unique Outcome: [20, 17, 14, 11, 8, 5, 2]
427
+ Occurrence: [3, 1, 1, 1, 1, 1, 2]
428
+ Probability: [0.3, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2]
429
+ Cummulative Probability: [0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1.0]
105
430
  ```
431
+
432
+
433
+ ### Randomsim
434
+
435
+ **Randomsim** helps to quickly simulate and generate a scenario with random values by just passing your desired argument values into it. It takes between 0 to 3 arguments. The generated results are then stored into the inter-arrival time and service time list needed to generate the rest of the values.
436
+
437
+ #### Methods
438
+
439
+ This class has eight methods that can be called on its instance namely:
440
+
441
+ * intarrival() ----> Displays the inter-arrival time in a list.
442
+ * arrival() ----> Displays the arrival time in a list.
443
+ * service() ----> Displays the service time in a list.
444
+ * servbegin() ----> Display the time service begins in a list.
445
+ * servend() ----> Display the time service ends in a list.
446
+ * queuewait() ----> Display the time the customer spent waiting in a list.
447
+ * custspend() ----> Display the time the customer spent in the system i.e. total time of service.
448
+ * idle() ---> Display the idle time of the server (cashier).
449
+
450
+ #### Usage
451
+ You can use the Randomsim class the following ways:
452
+
453
+
454
+ > The following examples will cover how arguments are used in the Generate class. In the examples, we assume that the class has been required first as
455
+
456
+ ```ruby
106
457
  require "Eventsims"
458
+ ```
459
+
460
+ and you can then respectively use it like in the following examples:
107
461
 
108
- sample = Eventsims::Simulate.new([0, 1, 5, 3, 5, 5, 3, 5, 5]) #can take two arguments.
109
- # or
110
- sample = Eventsims::Randomsim.new(5,8,9)
111
- puts "Inter-Arrival time: #{sample.intarrival()}"
112
- puts "Arrival time: #{sample.arrival()}"
113
- puts "Idle time: #{sample.idle()}"
462
+ ##### Example 1a
463
+
464
+ **zero arguments**
465
+
466
+ What this does is populate the inter-arrival and service time list with random numbers (between 1 and 10) random amount of times (2 to 20). The first value of the inter-arrival time defaults to 0.
467
+
468
+ ```ruby
469
+
470
+ sample = Eventsims::Randomsim.new()
471
+
472
+ puts "Inter-arrival time: #{sample.intarrival() } "
473
+ puts "Arrival time: #{sample.arrival() } "
474
+ puts "Service time: #{sample.service() } "
475
+ puts "Time when Service begins: #{sample.servbegin() } "
476
+ puts "Time when Service ends: #{sample.servend() } "
477
+ puts "Time customer spends waiting in Queue: #{sample.queuewait() } "
478
+ puts "Time customer spends in system: #{sample.custspend() } "
479
+ puts "Idle time of server: #{sample.idle() } "
114
480
  ```
115
481
 
116
- #### Result
482
+ ##### Result 1a
483
+
484
+ ```ruby
485
+ Inter-arrival time: [0, 8, 4, 10, 1]
486
+ Arrival time: [0, 8, 12, 22, 23]
487
+ Service time: [2, 9, 4, 5, 5]
488
+ Time when Service begins: [0, 8, 17, 22, 27]
489
+ Time when Service ends: [2, 17, 21, 27, 32]
490
+ Time customer spends waiting in Queue: [0, 0, 5, 0, 4]
491
+ Time customer spends in system: [2, 9, 9, 5, 9]
492
+ Idle time of server: [0, 6, 0, 1, 0]
117
493
  ```
118
- Inter-Arrival time: [0, 1, 5, 3, 5, 5, 3, 5, 5]
119
- Arrival time: [0, 1, 6, 9, 14, 19, 22, 27, 32]
120
- Idle time: [0, 0, 2, 0, 0, 0, 0, 0, 0]
494
+
495
+
496
+ ##### Example 1b
497
+
498
+ **one argument**
499
+
500
+ Usage: Eventsims::Randomsim.new(**list size**)
501
+
502
+ What this does is populate the inter-arrival and service time list with random numbers (between 1 and 10) the amount of times supplied as the only argument value. The first value of the inter-arrival time defaults to 0.
503
+
504
+ ```ruby
505
+ sample = Eventsims::Randomsim.new(6)
506
+
507
+ puts "Inter-arrival time: #{sample.intarrival() }"
508
+ puts "Arrival time: #{sample.arrival() }"
509
+ puts "Service time: #{sample.service() }"
510
+ puts "Time when Service begins: #{sample.servbegin() }"
511
+ puts "Time when Service ends: #{sample.servend() }"
512
+ puts "Time customer spends waiting in Queue: #{sample.queuewait() }"
513
+ puts "Time customer spends in system: #{sample.custspend() }"
514
+ puts "Idle time of server: #{sample.idle() }"
121
515
  ```
122
516
 
123
- ## Module methods
124
- ###trimval
517
+ ##### Result 1b
125
518
 
126
- **trimval** that takes in one argument, (numbers or lists and strips it of leading zeros and round up to 4 decimal places
127
519
 
128
- ## trimlist
520
+ ```ruby
521
+ Inter-arrival time: [0, 4, 10, 9, 1, 9]
522
+ Arrival time: [0, 4, 14, 23, 24, 33]
523
+ Service time: [4, 10, 1, 8, 10, 5]
524
+ Time when Service begins: [0, 4, 14, 23, 31, 41]
525
+ Time when Service ends: [4, 14, 15, 31, 41, 46]
526
+ Time customer spends waiting in Queue: [0, 0, 0, 0, 7, 8]
527
+ Time customer spends in system: [4, 10, 1, 8, 17, 13]
528
+ Idle time of server: [0, 0, 0, 8, 0, 0]
529
+ ```
530
+
129
531
 
130
- **trimlist** that takes in as many arguments as possibe and does the same thing **trimval** does but very useful if there is a nested list in the list of arguments.
532
+ ##### Example 1c
533
+
534
+ **two arguments**
131
535
 
132
- `
133
- They both help to display lists and numbers in a better and easier way to read rather than have values with many leading decimal numbers in a list keeping it concise. `
536
+ Usage: Eventsims::Randomsim.new(**max value**, **list size**)
134
537
 
135
- #### Usage example
538
+ What this does is populate the inter-arrival and service time list with numbers not more than the first argument starting from 1. The list is populated the amount of times specified as the second argument.
539
+
540
+ ```ruby
541
+ sample = Eventsims::Randomsim.new(4,6)
542
+
543
+ puts "Inter-arrival time: #{sample.intarrival() }"
544
+ puts "Arrival time: #{sample.arrival() }"
545
+ puts "Service time: #{sample.service() }"
546
+ puts "Time when Service begins: #{sample.servbegin() }"
547
+ puts "Time when Service ends: #{sample.servend() }"
548
+ puts "Time customer spends waiting in Queue: #{sample.queuewait() }"
549
+ puts "Time customer spends in system: #{sample.custspend() }"
550
+ puts "Idle time of server: #{sample.idle() }"
136
551
  ```
137
- require "Eventsims"
138
552
 
139
- sample = Eventsims.trimval([3.6789876])
140
- puts "new value: #{sample}"
141
553
 
554
+ ##### Result 1c
142
555
 
143
- sample = Eventsims.trimlist([3.6789876], "dog", [2.76542, "rat", [4]])
144
- puts "new list: #{sample}"
556
+ ```ruby
557
+ Inter-arrival time: [0, 1, 2, 2, 2, 4]
558
+ Arrival time: [0, 1, 3, 5, 7, 11]
559
+ Service time: [1, 2, 1, 4, 2, 4]
560
+ Time when Service begins: [0, 1, 3, 5, 9, 11]
561
+ Time when Service ends: [1, 3, 4, 9, 11, 15]
562
+ Time customer spends waiting in Queue: [0, 0, 0, 0, 2, 0]
563
+ Time customer spends in system: [1, 2, 1, 4, 4, 4]
564
+ Idle time of server: [0, 0, 0, 1, 0, 0]
145
565
  ```
146
-
147
- #### Result
566
+
567
+
568
+ ##### Example 1d
569
+
570
+ **three arguments**
571
+
572
+ Usage: Eventsims::Randomsim.new(**max value for inter-arrival time**, **max value for service time**, **list size**)
573
+
574
+ What this does is populate the inter-arrival with numbers between 1 and the value passed into the first argument, service time is populated with values between 1 and the second argument while the third argument is the amount/size of the two lists.
575
+
576
+ ```ruby
577
+ sample = Eventsims::Randomsim.new(4, 6, 8)
578
+
579
+ puts "Inter-arrival time: #{sample.intarrival() } "
580
+ puts "Arrival time: #{sample.arrival() } "
581
+ puts "Service time: #{sample.service() } "
582
+ puts "Time when Service begins: #{sample.servbegin() } "
583
+ puts "Time when Service ends: #{sample.servend() } "
584
+ puts "Time customer spends waiting in Queue: #{sample.queuewait() } "
585
+ puts "Time customer spends in system: #{sample.custspend() } "
586
+ puts "Idle time of server: #{sample.idle() } "
148
587
  ```
149
- new val: [[3.679]]
150
- new list: [[3.679], "dog", [2.7654, "rat", [4]]
588
+
589
+
590
+ ##### Result 1d
591
+
592
+
593
+ ```ruby
594
+ Inter-arrival time: [0, 3, 2, 2, 3, 3, 3, 4]
595
+ Arrival time: [0, 3, 5, 7, 10, 13, 16, 20]
596
+ Service time: [6, 2, 2, 2, 4, 5, 6, 4]
597
+ Time when Service begins: [0, 6, 8, 10, 12, 16, 21, 27]
598
+ Time when Service ends: [6, 8, 10, 12, 16, 21, 27, 31]
599
+ Time customer spends waiting in Queue: [0, 3, 3, 3, 2, 3, 5, 7]
600
+ Time customer spends in system: [6, 5, 5, 5, 6, 8, 11, 11]
601
+ Idle time of server: [0, 0, 0, 0, 0, 0, 0, 0]
151
602
  ```
152
603
 
153
- ## Requirements
154
604
 
605
+ ### Simulate
155
606
 
156
- * Any version of Ruby
607
+ **Simulate** helps to quickly simulate and generate a scenario with user-defined values. It is more flexible in that it allows you to input your own data rather than input just numbers as compared to **Randomsim**. It can take one or two arguments which are inter-arrival time list and service time list. They must be of the same length.
157
608
 
609
+ #### Methods
158
610
 
159
- ## Installation
611
+ This class has eight methods (same as `Randomsim`) that can be called on its instance namely:
612
+
613
+ * intarrival() ----> Displays the inter-arrival time in a list.
614
+ * arrival() ----> Displays the arrival time in a list.
615
+ * service() ----> Displays the service time in a list.
616
+ * servbegin() ----> Display the time service begins in a list.
617
+ * servend() ----> Display the time service ends in a list.
618
+ * queuewait() ----> Display the time the customer spent waiting in a list.
619
+ * custspend() ----> Display the time the customer spent in the system i.e. total time of service.
620
+ * idle() ---> Display the idle time of the server (cashier).
160
621
 
161
- Add this line to your application's Gemfile:
622
+
623
+ #### Usage
624
+
625
+ >The following examples will cover how arguments are used in the Simulate class. In the examples, we assume that the class has been required first as:
162
626
 
163
627
  ```ruby
164
- gem 'eventsims'
628
+ require "Eventsims"
165
629
  ```
166
630
 
167
- And then execute:
631
+ ##### Example 2a
168
632
 
169
- $ bundle
633
+ **one argument**
170
634
 
171
- Or install it yourself as:
635
+ Usage: Eventsims::Simulate.new(**inter-arrival list**)
172
636
 
173
- $ gem install eventsims
637
+ What this does is populate the inter-arrival time with the user-defined argument (**must be a list**) and service time would be automatically generated (populated with numbers between 1 and 10 with the same size as inter-arrival time).
638
+
639
+ ```ruby
640
+ sample = Eventsims::Simulate.new([7, 9, 6])
641
+
642
+ puts "Inter-arrival time: #{sample.intarrival() } "
643
+ puts "Arrival time: #{sample.arrival() } "
644
+ puts "Service time: #{sample.service() } "
645
+ puts "Time when Service begins: #{sample.servbegin() } "
646
+ puts "Time when Service ends: #{sample.servend() } "
647
+ puts "Time customer spends waiting in Queue: #{sample.queuewait() } "
648
+ puts "Time customer spends in system: #{sample.custspend() } "
649
+ puts "Idle time of server: #{sample.idle() } "
650
+ ```
651
+
652
+ ##### Result 2a
653
+
654
+ ```ruby
655
+ Inter-arrival time: [7, 9, 6]
656
+ Arrival time: [7, 16, 22]
657
+ Service time: [2, 5, 1]
658
+ Time when Service begins: [7, 16, 22]
659
+ Time when Service ends: [9, 21, 23]
660
+ Time customer spends waiting in Queue: [0, 0, 0]
661
+ Time customer spends in system: [2, 5, 1]
662
+ Idle time of server: [0, 7, 1]
663
+ ```
664
+
665
+
666
+ ##### Example 2b
667
+
668
+ **two arguments**
174
669
 
670
+ Usage: Eventsims::Randomsim.new(**inter-arrival list**, **service time list**)
671
+
672
+ What this does is populate the inter-arrival with the first list argument and the service time with the second argument which is then used to calcuate the the rest.
673
+
674
+ ```ruby
675
+ sample = Eventsims::Simulate.new([0, 5, 6, 3, 7, 9, 3], [4, 7, 2, 1, 3, 11, 7])
676
+
677
+ puts "Inter-arrival time: #{sample.intarrival() } "
678
+ puts "Arrival time: #{sample.arrival() } "
679
+ puts "Service time: #{sample.service() } "
680
+ puts "Time when Service begins: #{sample.servbegin() } "
681
+ puts "Time when Service ends: #{sample.servend() } "
682
+ puts "Time customer spends waiting in Queue: #{sample.queuewait() } "
683
+ puts "Time customer spends in system: #{sample.custspend() } "
684
+ puts "Idle time of server: #{sample.idle() } "
685
+ ```
175
686
 
687
+ ##### Result 2b
176
688
 
177
- ## Development
689
+
690
+ ```ruby
691
+ Inter-arrival time: [0, 5, 6, 3, 7, 9, 3]
692
+ Arrival time: [0, 5, 11, 14, 21, 30, 33]
693
+ Service time: [4, 7, 2, 1, 3, 11, 7]
694
+ Time when Service begins: [0, 5, 12, 14, 21, 30, 41]
695
+ Time when Service ends: [4, 12, 14, 15, 24, 41, 48]
696
+ Time customer spends waiting in Queue: [0, 0, 1, 0, 0, 0, 8]
697
+ Time customer spends in system: [4, 7, 3, 1, 3, 11, 15]
698
+ Idle time of server: [0, 1, 0, 0, 6, 6, 0]
699
+ ```
700
+
701
+
702
+ ## Module methods
703
+ ### trimval
704
+
705
+ **trimval** that takes in one argument, (numbers or lists and strips it of leading zeros and round up to 4 decimal places
706
+
707
+ ### trimlist
708
+
709
+ **trimlist** that takes in as many arguments as possibe and does the same thing **trimval** does but very useful if there is a nested list in the list of arguments.
710
+
711
+
712
+ > They both help to display lists and numbers in a better and easier way to read rather than have values with many leading decimal numbers in a list(Array) keeping it concise. `
713
+
714
+ #### Usage
715
+
716
+ Usage: Eventsims::trimval(**single argument**)
717
+ Usage: Eventsims::trimlist(**any Array argument**)
718
+
719
+ ##### example
720
+ ```ruby
721
+ require "Eventsims"
722
+
723
+ sample = Eventsims.trimval([3.6789876])
724
+ puts "new value: #{sample}"
725
+
726
+ sample = Eventsims.trimlist([3.6789876], "dog", [2.76542, "rat", [4]])
727
+ puts "new list: #{sample}"
728
+ ```
729
+
730
+ ##### Result
731
+ ```ruby
732
+ new val: [[3.679]]
733
+ new list: [[3.679], "dog", [2.7654, "rat", [4]]
734
+ ```
735
+
736
+
737
+
738
+ <!-- ## Development
178
739
 
179
740
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
180
741
 
181
742
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
182
-
743
+ -->
183
744
  ## Contributing
184
745
 
185
746
  Bug reports and pull requests are welcome on GitHub at https://github.com/tushortz/eventsims.
@@ -188,4 +749,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/tushor
188
749
  ## License
189
750
 
190
751
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
191
-
File without changes
data/bin/setup CHANGED
File without changes
@@ -1,5 +1,5 @@
1
1
 
2
- module Randgen
2
+ module Eventsims
3
3
 
4
4
 
5
5
  # Generating random outcomes and probabilities
@@ -1,6 +1,7 @@
1
1
  module Eventsims
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
4
+
4
5
 
5
6
  #Files
6
7
  # --> 1 = discrete.rb
Binary file
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventsims
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taiwo Kareem
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-30 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  description: 'Eventsims is a Ruby package for simulating discrete event. It has four
@@ -47,10 +47,9 @@ executables: []
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
- - .Gemfile.lock.swp
51
- - .gitignore
52
- - .rspec
50
+ - ".rspec"
53
51
  - Gemfile
52
+ - Gemfile.lock
54
53
  - Guardfile
55
54
  - LICENSE.txt
56
55
  - README.md
@@ -63,6 +62,7 @@ files:
63
62
  - lib/eventsims/randgen.rb
64
63
  - lib/eventsims/simevent.rb
65
64
  - lib/eventsims/version.rb
65
+ - pkg/eventsims-0.0.1.gem
66
66
  homepage: http://github.com/tushortz/eventsims
67
67
  licenses:
68
68
  - MIT
@@ -73,17 +73,17 @@ require_paths:
73
73
  - lib
74
74
  required_ruby_version: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - '>='
76
+ - - ">="
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - '>='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  requirements: []
85
85
  rubyforge_project:
86
- rubygems_version: 2.0.14
86
+ rubygems_version: 2.4.8
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: Eventsims uses various useful tools in simulating discrete system events
Binary file
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/