Re: "bootstrap" statistics [message #30847 is a reply to message #30844] |
Mon, 20 May 2002 13:58  |
Wayne Landsman
Messages: 117 Registered: January 1997
|
Senior Member |
|
|
> I have found:
>
> http://www.astro.washington.edu/deutsch-bin/getpro/library14 .html?PERMUTE
>
> which is a somewhat better way, but still slow. Is there a no-loops version?
Interesting question. I had modified the above PERMUTE program to use a
vector call to RANDOMN(/DOUBLE), (the /DOUBLE keyword has been available since
V5.4). My feeling was that with ~5e15 distinct double precision numbers
between 0 and 1, that probablity of RANDOMN returning two identical numbers was
vanishingly small, in a typical call of say less than 10,000 numbers
But I've never been comfortable enough with the modification to actually use
it. I suppose I should add a check for any equal numbers in the
RANDOMN(/DOUBLE) call, and then randomize those numbers.
--Wayne
FUNCTION PERMUTE,M, RSEED, OUTSEED = seed
;+
; NAME:
; PERMUTE
; PURPOSE:
; Randomly permute the elements of a vector
; USAGE:
; NewIndex = PERMUTE( M, [ InSeed, OUTSEED = ] )
; INPUT:
; M = length of vector
; OPTIONAL INPUT-OUTPUT:
; SEED = random number seed to be passed to RANDOMU
; Upon return, it will updated as a vector containing a new seed
; OUTPUT:
; PERMUTE returns M randomly shuffled integers between 0 and M-1
; EXAMPLE:
; To shuffle the elements of a vector V,
;
; V = V [ PERMUTE(N_ELEMENTS(V) ) ]
;
; REVISION HISTORY:
; Written, H.T. Freudenreich, HSTX, 2/95
; Use vectorized call W. Landsman SSAI December 2001
;-
;
; Select M numbers at random, repeating none.
if N_elements(rseed) GT 0 then seed = rseed
return, sort( randomn(seed, m,/Double) )
|
|
|