octave-maintainers
[Top][All Lists]

## Re: Package statistics: tricdf (bug?)

 From: Evangelos Rozos Subject: Re: Package statistics: tricdf (bug?) Date: Thu, 25 Jun 2020 10:00:45 +0300 User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

Thank you for you reply. This patch fixes tricdf for scalar arguments (triinv has also problem). Are the developers aware of it, should we file a bug?

On 25/06/2020 01:39, Dmitri A. Sergatskov wrote:

On Tue, Jun 23, 2020 at 5:37 AM Evangelos Rozos <erozos@gmail.com> wrote:
I think something is wrong with tricdf function (maybe triinv also).

>> tricdf (0.7, 0.5, 1.0, 0.9)

ans =  0.16000

The correct answer should be 0.2.

MATLAB gives 0.2. This value can be also verified by the geometry of the
pdf triangle with base from 0.5 to 1, and height 4 at 0.9. Then, the
area of the triangle with base from 0.5 to 0.7 and height 2 (0.7 is in
the middle of the 0.5 to 0.9 segment) is 0.2.

tricdf code has few problems.  For you reported problem this fix should work:
<     area = (x(k_temp) - a).^2 * h;
---
>     area = (x(k_temp) - a).^2 * h / (c - a) / 2 ;
74c74
<     area = (b-x(k_temp)).^2 * h;
---
>     area = (b-x(k_temp)).^2 * h / (b - c) / 2 ;

A similar change should be done for the code segment that deals with the case of
A,B, and C being arrays rather than scalar. I really do not understand the intent of that code.
It requires the size of X, A, B, and C to be the same. That does not make much sense to me.
I think A, B and C should be scalars. I do not think there is a compatible matlab's function.

Dmitri.
--