Re: help on bootstrap sample
- To: mathgroup at smc.vnet.net
- Subject: [mg37368] Re: [mg37338] help on bootstrap sample
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Fri, 25 Oct 2002 02:47:21 -0400 (EDT)
- References: <200210240655.CAA05072@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Søren Merser wrote:
>
> Hi Mathematica freeks
> I've made two small rutines for sampling (bootstrap statistics)
> They are working , but at least 'SampleNoReplace' is rather slow
> I was wondering if any of you know of a faster way to do this
> Regards soren
>
> SampelReplace[data_List:{0, 1}, n_:1] :=
> Module[{}, data[[Table[Random[Integer, {1, Length@data} ], {n}]]]]
>
> SampelNoReplace[data_List, n_] := Module[{idx, len, res, d, hi, i},
> d = data;
> res = {};
> len = hi = Length@d;
>
> For[i = 1, i <= n && i <= len, i++,
> idx = Random[Integer, {1, hi--} ];
> AppendTo[res, d[[idx]]];
> d = Drop[d, {idx}];
> ];
> res
> ]
This comes up from time to time. Have a look at
http://forums.wolfram.com/mathgroup/archive/2001/Jan/msg00087.html
or
http://forums.wolfram.com/mathgroup/archive/2001/Apr/msg00263.html
Daniel Lichtblau
Wolfram Research
- References:
- help on bootstrap sample
- From: Søren Merser <merser@image.dk>
- help on bootstrap sample