Random values consistent with a best-fit curve
I'm contemplating the generation of test data with interesting distributions.
I understand methods for the generation of uniform distribution and normal distribution, but how can I transform an arbitrary function into a weighted distribution function? My terminology may be off here - I won't mind corrections.
For example, let's say that I have a function over time which generally increases, but cycles periodically. "Activity" which increases generally over a year, but weekly cycles with sharp falloff on the weekends.
The function could be algebraic, but it would be valuable if it could be any function (imperative(?) with discrete/discontinuous ranges(?)).
If the Activity curve from the example is f(t)
, I could just make f(t)
the mean and provide a fixed standard deviation, but how do I chose t
if it too needs distribution? I don't want to have to iterate through T
, I just want to select among T
randomly with the appropriate distributions.
So the TestActivityGenerator() function takes parameters for curves between, say, an absolute date range, another curve over weeks, and another curve over hours in the day, and spits out DateTimes in the proper distributions. Results are not generated in any specific ordering.
Another scenario might be: a generator of reals which is, say, 1.652 times more likely to spit out a prime number than a composite. No tricks on this one -开发者_C百科 there are trivial ways to do this, but I'm looking for a general solution.
Thanks!
Edit: I've change the wording of the title to look at the problem from a different angle - How can we backtrack from a curve of best-fit to random samples that are consistent with that curve. If I have a histogram of stock market data, how can I generate data that is distributed similarly to the real data. Not just pairwise-values that average to the same value for each t
, because they would fail other randomness tests.
精彩评论