comparison scripts/statistics/distributions/frnd.m @ 11587:c792872f8942

all script files: untabify and strip trailing whitespace
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:35:29 -0500
parents fd0a3ac60b0e
children c21eb9c02c31
comparison
equal deleted inserted replaced
11586:12df7854fa7c 11587:c792872f8942
20 ## @deftypefn {Function File} {} frnd (@var{m}, @var{n}, @var{r}, @var{c}) 20 ## @deftypefn {Function File} {} frnd (@var{m}, @var{n}, @var{r}, @var{c})
21 ## @deftypefnx {Function File} {} frnd (@var{m}, @var{n}, @var{sz}) 21 ## @deftypefnx {Function File} {} frnd (@var{m}, @var{n}, @var{sz})
22 ## Return an @var{r} by @var{c} matrix of random samples from the F 22 ## Return an @var{r} by @var{c} matrix of random samples from the F
23 ## distribution with @var{m} and @var{n} degrees of freedom. Both 23 ## distribution with @var{m} and @var{n} degrees of freedom. Both
24 ## @var{m} and @var{n} must be scalar or of size @var{r} by @var{c}. 24 ## @var{m} and @var{n} must be scalar or of size @var{r} by @var{c}.
25 ## If @var{sz} is a vector the random samples are in a matrix of 25 ## If @var{sz} is a vector the random samples are in a matrix of
26 ## size @var{sz}. 26 ## size @var{sz}.
27 ## 27 ##
28 ## If @var{r} and @var{c} are omitted, the size of the result matrix is 28 ## If @var{r} and @var{c} are omitted, the size of the result matrix is
29 ## the common size of @var{m} and @var{n}. 29 ## the common size of @var{m} and @var{n}.
30 ## @end deftypefn 30 ## @end deftypefn
33 ## Description: Random deviates from the F distribution 33 ## Description: Random deviates from the F distribution
34 34
35 function rnd = frnd (m, n, r, c) 35 function rnd = frnd (m, n, r, c)
36 36
37 if (nargin > 1) 37 if (nargin > 1)
38 if (!isscalar(m) || !isscalar(n)) 38 if (!isscalar(m) || !isscalar(n))
39 [retval, m, n] = common_size (m, n); 39 [retval, m, n] = common_size (m, n);
40 if (retval > 0) 40 if (retval > 0)
41 error ("frnd: M and N must be of common size or scalar"); 41 error ("frnd: M and N must be of common size or scalar");
42 endif 42 endif
43 endif 43 endif
83 rnd = ones (sz); 83 rnd = ones (sz);
84 else 84 else
85 rnd = 2 ./ m .* randg(m / 2, sz); 85 rnd = 2 ./ m .* randg(m / 2, sz);
86 endif 86 endif
87 if (! isinf (n)) 87 if (! isinf (n))
88 rnd = 0.5 .* n .* rnd ./ randg (n / 2, sz); 88 rnd = 0.5 .* n .* rnd ./ randg (n / 2, sz);
89 endif 89 endif
90 elseif ((m > 0) && (m < Inf) && (n > 0) && (n < Inf)) 90 elseif ((m > 0) && (m < Inf) && (n > 0) && (n < Inf))
91 rnd = n ./ m .* randg (m / 2, sz) ./ randg (n / 2, sz); 91 rnd = n ./ m .* randg (m / 2, sz) ./ randg (n / 2, sz);
92 else 92 else
93 rnd = NaN (sz); 93 rnd = NaN (sz);