[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: consistent crash using gammrnd
From: |
David Bateman |
Subject: |
Re: consistent crash using gammrnd |
Date: |
Mon, 16 Jul 2007 12:03:15 +0200 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060921) |
David Bateman wrote:
> Hermann wrote:
>
>> Am Samstag, 14. Juli 2007 schrieb Paul Kienzle:
>>
>>
>>
>>>> gamrnd(rand(100,1),rand(100,1))
>>>>
>>>>
>>> The attached patch fixes the gamrnd bug ... it was doing
>>> vector/vector rather than vector./vector.
>>>
>>>
>> Hi,
>> I’m not sure, but maybe this should be .* instead of ./ ? I noted that
>> in 'help randg' it sais
>>
>> | This can be used to generate many distributions:
>> |
>> | `gamma (a, b)' for `a > -1', `b > 0'
>> | r = b * randg (a)
>>
>>
>>
> Well, yes and no.. The current definition of gampdf, gamcdf and gamrnd
> use a definition of 1/mu for the parameter B. So the current behavior of
> gamrnd is consistent with gamcdf, gampdf and gaminv. Unfortunately this
> seems to be the reverse of what is done in Matlab. For compatibility its
> probably better to mimic the matlab behavior. Consider the attached
> patch that changes the behavior to be consistent with matlab.. Note that
> exppdf, etc are also concerned are they are really just special cases of
> the gamma distributions.
>
> Do the other statistics functions have the same issues? I don't have the
> statistics toolbox for matlab and so can't easily check...
>
> D.
>
Thinking about it further, there are the functions
deprecated/exponential_* and deprecated/gamma_* that have effectively
had their behavior changed due to patch I just sent. To preserve
backward compatibility, the attached patch should also be applied.
D.
--
David Bateman address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax)
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
*** ./scripts/deprecated/gamma_rnd.m.orig44 2007-07-16 11:56:36.820032699
+0200
--- ./scripts/deprecated/gamma_rnd.m 2007-07-16 11:57:25.810588673 +0200
***************
*** 34,39 ****
--- 34,43 ----
function rnd = gamma_rnd (varargin)
+ if (nargin > 1)
+ varargin{2} = 1 ./ varargin{2};
+ endif
+
rnd = gamrnd (varargin{:});
endfunction
*** ./scripts/deprecated/gamma_pdf.m.orig44 2007-07-16 11:56:43.277710702
+0200
--- ./scripts/deprecated/gamma_pdf.m 2007-07-16 11:57:57.380012261 +0200
***************
*** 29,34 ****
--- 29,38 ----
function pdf = gamma_pdf (varargin)
+ if (nargin > 2)
+ varargin{3} = 1 ./ varargin{3};
+ endif
+
pdf = gampdf (varargin{:});
endfunction
*** ./scripts/deprecated/gamma_cdf.m.orig44 2007-07-16 11:56:47.807484806
+0200
--- ./scripts/deprecated/gamma_cdf.m 2007-07-16 11:58:04.293666876 +0200
***************
*** 29,34 ****
--- 29,38 ----
function cdf = gamma_cdf (varargin)
+ if (nargin > 2)
+ varargin{3} = 1 ./ varargin{3};
+ endif
+
cdf = gamcdf (varargin{:});
endfunction
*** ./scripts/deprecated/gamma_inv.m.orig44 2007-07-16 11:56:53.744188712
+0200
--- ./scripts/deprecated/gamma_inv.m 2007-07-16 11:58:11.558303899 +0200
***************
*** 29,34 ****
--- 29,38 ----
function inv = gamma_inv (varargin)
+ if (nargin > 2)
+ varargin{3} = 1 ./ varargin{3};
+ endif
+
inv = gaminv (varargin{:});
endfunction
*** ./scripts/deprecated/exponential_rnd.m.orig44 2007-07-16
11:57:04.304661901 +0200
--- ./scripts/deprecated/exponential_rnd.m 2007-07-16 11:59:11.102326537
+0200
***************
*** 34,39 ****
--- 34,43 ----
function rnd = exponential_rnd (varargin)
+ if (nargin > 0)
+ varargin{1} = 1 ./ varargin{1};
+ endif
+
rnd = exprnd (varargin{:});
endfunction
*** ./scripts/deprecated/exponential_pdf.m.orig44 2007-07-16
11:57:10.513352119 +0200
--- ./scripts/deprecated/exponential_pdf.m 2007-07-16 11:58:38.090977685
+0200
***************
*** 28,33 ****
--- 28,37 ----
function pdf = exponential_pdf (varargin)
+ if (nargin > 1)
+ varargin{2} = 1 ./ varargin{2};
+ endif
+
pdf = exppdf (varargin{:});
endfunction
*** ./scripts/deprecated/exponential_cdf.m.orig44 2007-07-16
11:57:14.673144541 +0200
--- ./scripts/deprecated/exponential_cdf.m 2007-07-16 11:58:52.764243914
+0200
***************
*** 31,36 ****
--- 31,40 ----
function cdf = exponential_cdf (varargin)
+ if (nargin > 1)
+ varargin{2} = 1 ./ varargin{2};
+ endif
+
cdf = expcdf (varargin{:});
endfunction
*** ./scripts/deprecated/exponential_inv.m.orig44 2007-07-16
11:57:20.819837778 +0200
--- ./scripts/deprecated/exponential_inv.m 2007-07-16 11:58:31.193322535
+0200
***************
*** 29,34 ****
--- 29,38 ----
function inv = exponential_inv (varargin)
+ if (nargin > 1)
+ varargin{2} = 1 ./ varargin{2};
+ endif
+
inv = expinv (varargin{:});
endfunction
2007-07-16 David Bateman <address@hidden>
* deprecated/gamma_cdf.m, deprecated/gamma_inv.m,
deprecated/gamma_pdf.m, deprecated/gamma_rnd.m,
deprecated/exponential_cdf.m, deprecated/exponential_inv.m,
deprecated/exponential_pdf.m, deprecated/exponential_rnd.m:
Preserve backward compatibility.
- consistent crash using gammrnd, Daniel Oberhoff, 2007/07/13
- Re: consistent crash using gammrnd, David Bateman, 2007/07/13
- Re: consistent crash using gammrnd, Paul Kienzle, 2007/07/13
- Re: consistent crash using gammrnd, John W. Eaton, 2007/07/18
- Re: consistent crash using gammrnd, David Bateman, 2007/07/18
- Re: consistent crash using gammrnd, Daniel Oberhoff, 2007/07/20
- Re: consistent crash using gammrnd, David Bateman, 2007/07/23
- Re: consistent crash using gammrnd, Daniel Oberhoff, 2007/07/23
- Re: consistent crash using gammrnd, David Bateman, 2007/07/23
- Re: consistent crash using gammrnd, Daniel Oberhoff, 2007/07/23
- Re: consistent crash using gammrnd, David Bateman, 2007/07/24