[ + np min(np where (np cumsum ( [ [ ,:]np random rand ()) #add to all elements of the vector plt plot(np array range ( , )), ' 'plt plot(np array range ( , )), '--'plt show (resampling resampling the idea behind resampling is very simplean iid sample :{ xn from some unknown cdf represents our best knowledge of if we make no further priori assumptions about it if it is not possible to simulate more samples from fthe best way to "repeatthe experiment is to resample from the original data by drawing from the empirical cdf fn see ( that iswe draw each xi with equal probability and repeat this timesaccording to algorithm below as we draw here "with replacement"multiple instances of the original data points may occur in the resampled data algorithm sampling from an empirical cdf inputoriginal iid sample xn and sample size outputiid sample xnfrom the empirical cdf for to do draw ( set dnue set xtxi return xnin step dnue returns the ceiling of nuthat isit is the smallest integer larger than or equal to nu consequentlyi is drawn uniformly at random from the set of indices { nby sampling from the empirical cdf we can thus (approximatelyrepeat the experiment that gave us the original data as many times as we like this is useful if we want to assess the properties of certain statistics obtained from the data for examplesuppose that the original data gave the statistic (tby resampling we can gain information about the distribution of the corresponding random variable ( example (quotient of uniformslet un vn be iid ( random variables and define xi ui /vi suppose we wish to investigate the distribue and sample mean of the (randomdata :{ xn tion of the sample median since we know the model for exactlywe can generate large numbern sayof indee en pendent copies of itand for each of these copies evaluate the sample medians and sample means for and the empirical cdfs might look like the left and right curves in figure respectively contrary to what you might have expectedthe distributions of the sample median and sample mean do not match at all the sample median is quite concentrated around whereas the distribution of the sample mean is much more spread out