How To Make A Sample From The Empirical Distribution Function
I'm trying to implement the nonparametric bootstrapping on Python. It requires to take a sample, build an empirical distribution function from it and then to generate a bunch of sa
Solution 1:
The edf you get by sorting the samples:
N = samples.size
ss = np.sort(samples) # these are the x-values of the edf# the y-values are 1/(2N), 3/(2N), 5/(2N) etc.edf = lambda x: np.searchsorted(ss, x) / N
However, if you only want to resample then you simply draw from your sample with equal probability and replacement.
If this is too "steppy" for your liking, you can probably use some kind of interpolation to get a smooth distribution.
Post a Comment for "How To Make A Sample From The Empirical Distribution Function"