-1

I am working on a simulation project. Need help on random number generation. I need two sets of random numbers.

Properties:

  1. Primary set (var_a) > Normally distributed, greater than 0, with given mean and std.
  2. Secondary set (var_b) -> Same as a primary set, with an addition, that second set cannot be greater than primary set. The reason being the output of a deterministic function will be in percentage between 0-1 only. For example:

service level calculation

import numpy as np

n = 100000

# Calls Handled
callshandled = np.random.normal(loc=65,  scale=97, size=n)
print('Calls handled: ', callshandled)

# Call handled within sl. Has to always be less or equal to Calls Handled
ansinsl = np.random.normal(loc=60,  scale=82, size=n)
print('Answered in SL', ansinsl)

# Service Level - Has to be between 0-1. With normal distribution we get values in negative
sl = np.array(ansinsl)/np.array(callshandled)
print('Service level', sl)

Calls handled:  [ 43.26825426 129.79198758  31.56460354 ...  37.45059791   1.71420416
 -94.87241356]
Answered in SL [-12.72293091 204.28084996 232.25722235 ... 166.03208722 -53.69933624
 -36.71949656]
Service level [ -0.29404771   1.57390956   7.35815427 ...   4.43336279 -31.32610312
   0.38704082]

1 Answers1

0

There is a well-known “natural” way of generating pairs of Gaussian pseudo-random variates, known as Box-Muller.

You could try it that way:

  1. generate pairs of unit normal variates à la Box-Muller
  2. scale the pairs to whatever your (µ,σ) parameters are
  3. reject the pairs that do not fit your criteria
jpmarinier
  • 4,427
  • 1
  • 10
  • 23