/usr/share/gnudatalanguage/astrolib/randomdir.pro is in gdl-astrolib 2018.02.16+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+
; NAME:
; RANDOMDIR
; PURPOSE:
; GENERATE DIRICHLET-DISTRIBUTED RANDOM VARIABLES.
;
; AUTHOR : BRANDON C. KELLY, STEWARD OBS., APRIL 2006
;
; INPUTS :
;
; SEED - THE SEED FOR THE RANDOM NUMBER GENERATOR, CAN BE UNDEFINED.
; ALPHA - THE SHAPE PARAMETERS FOR THE DIRICHLET DISTRIBUTION. THIS
; SHOULD BE A K-ELEMENT VECTOR.
;
; OPTIONAL INPUTS :
;
; NRAND - THE NUMBER OF RANDOM NUMBERS TO DRAW
;
; CALLED ROUTINES :
;
; RANDOMGAM
;-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
function randomdir, seed, alpha, nrand
if n_params() lt 2 then begin
print, 'Syntax- theta = randomdir( seed, alpha[, nrand] )'
return, 0
endif
if n_elements(alpha) lt 2 then begin
print, 'Alpha must have at least 2 elements.'
return, 0
endif
K = n_elements(alpha)
bad = where(alpha le 0, nbad)
if nbad ne 0 then begin
print, 'All elements of ALPHA must be greater than 0.'
return, 0
endif
if n_elements(nrand) eq 0 then nrand = 1
gamma = dblarr(nrand, K)
for j = 0, K - 1 do $
gamma[0,j] = randomgam(seed, alpha[j], 1.0, nrand)
theta = gamma / transpose(total(gamma,2) ## replicate(1, K))
return, theta
end
|