Hello, I was wondering if scipy had something similar to Octave/Matlab's empricial_rnd(). Here's the blurb from Octave's help describing the function: -- Function File: empirical_rnd (N, DATA) -- Function File: empirical_rnd (DATA, R, C) -- Function File: empirical_rnd (DATA, SZ) Generate a bootstrap sample of size N from the empirical distribution obtained from the univariate sample DATA. If R and C are given create a matrix with R rows and C columns. Or if SZ is a vector, create a matrix of size SZ. So basically you pass it an array of data, and it returns bootstrap samples (resampling from the array with replacement). I did a quick search on 'scipy bootstrap', 'scipy distributions' and 'scipy empirical_rnd', but didn't turn up anything promising. Any help / pointers greatly appreciated. Thanks. -- Joshua Stults Website: http://j-stults.blogspot.com
On Tue, Jul 7, 2009 at 6:28 AM, Joshua Stults<joshua.stults@gmail.com> wrote:
Hello,
I was wondering if scipy had something similar to Octave/Matlab's empricial_rnd(). Here's the blurb from Octave's help describing the function:
-- Function File: empirical_rnd (N, DATA) -- Function File: empirical_rnd (DATA, R, C) -- Function File: empirical_rnd (DATA, SZ) Generate a bootstrap sample of size N from the empirical distribution obtained from the univariate sample DATA.
If R and C are given create a matrix with R rows and C columns. Or if SZ is a vector, create a matrix of size SZ.
So basically you pass it an array of data, and it returns bootstrap samples (resampling from the array with replacement).
I did a quick search on 'scipy bootstrap', 'scipy distributions' and 'scipy empirical_rnd', but didn't turn up anything promising. Any help / pointers greatly appreciated. Thanks.
-- Joshua Stults Website: http://j-stults.blogspot.com _______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
I was looking for bootstrap in python a while ago and didn't find much except for one blog post. Drawing from the data array can be done with random integers as indices: d is data array sample_size = len(d) # Choose #sample_size members of d at random, with replacement choices = numpy.random.random_integers(0, sample_size-1, sample_size) sample = d[choices] Josef
7/07/09 @ 06:28 (-0400), thus spake Joshua Stults:
So basically you pass it an array of data, and it returns bootstrap samples (resampling from the array with replacement).
You can use the random module from Python: In [40]: d = (1,2,3,4) In [41]: [random.choice(d) for i in range(len(d))] Out[41]: [4, 4, 2, 1] In [42]: [random.choice(d) for i in range(len(d))] Out[42]: [4, 2, 4, 2] In [43]: [random.choice(d) for i in range(len(d))] Out[43]: [2, 1, 2, 3] Bye. Ernest
participants (3)
-
Ernest Adrogué
-
josef.pktd@gmail.com
-
Joshua Stults