I am trying to automate functional testing of a server using a realistic frequency distribution of requests. (sort of load testing, sort of simulation)
I’ve chosen the Weibull distribution as it ‘sort of’ matches the distribution I’ve observed (ramps up quickly, drops off quickly but not instantly)
I use this distribution to generate the number of requests that should be sent each day between a given start and end date
I’ve hacked together an algorithm in Python that sort of works but it feels kludgy:
how_many_days = (end_date - start_date).days freqs = defaultdict(int) for x in xrange(how_many_responses): freqs[int(how_many_days * weibullvariate(0.5, 2))] += 1 timeline = [] day = start_date for i,freq in sorted(freqs.iteritems()): timeline.append((day, freq)) day += timedelta(days=1) return timeline
What better ways are there to do this?
This is quick and probably not that accurate, but if you calculate the PDF yourself, then at least you make it easier to lay several smaller/larger ones on a single timeline.
devis the std deviation in the Guassian noise, which controls the roughness. Note that this is not the ‘right’ way to generate what you want, but it’s easy.