octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #60113] Function 'triinv(x, a, b, c)' from 'st


From: anonymous
Subject: [Octave-bug-tracker] [bug #60113] Function 'triinv(x, a, b, c)' from 'statistics' package returns incorrect values
Date: Thu, 25 Feb 2021 04:23:15 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0

URL:
  <https://savannah.gnu.org/bugs/?60113>

                 Summary: Function 'triinv(x, a, b, c)' from 'statistics'
package returns incorrect values
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Thu 25 Feb 2021 09:23:13 AM UTC
                Category: Octave Forge Package
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: 5.2.0
         Discussion Lock: Any
        Operating System: Any

    _______________________________________________________

Details:

The function 'triinv(x, a, b, c)' from the Octave Forge package 'statistics'
produces output that doesn't look right to me. 

I am using statistics-1.4.2.tar.gz downloaded and installed on 25/02/2021 and
Octave version 5.2.0. I have uninstalled and re-installed a clean download of
the package several times and got identical results each time. I think this
problem will occur on any system but for information I am using a Dell
Latitude E6230 laptop with Intel Core i5-3340M CPU @ 2.70GHz and 4GB of RAM
running Xubuntu 20.04.2 LTS. 

The attached file figure1.jpg shows a plot of y = triinv(x, 2, 5, 3). This
contains a large discontinuity which it clearly shouldn't have. 

figure2.jpg shows the same plot using a quick and dirty implementation of the
formula for the quantile function of the triangular random variable with the
same arguments. (See https://en.wikipedia.org/wiki/Triangular_distribution
(section entitled "Generating triangular-distributed random variates") or
https://github.com/distributions-io/triangular-quantile.) This is what the
curve should look like. 

I think the error is in lines 61 and 65 of the file 'triinv.m'. These lines
don't embody the correct formula for the quantile function. (h/2) should
appear as a divisor not a multiplier. 

Line 61 currently says:


inv(j) += (x(j) * (h/2) * w).^0.5 + a;


but should say:


inv(j) += (x(j) * w / (h/2)).^0.5 + a;


Line 65 currently says:


inv(j) += b - ((1-x(j)) * (h/2) * w).^0.5;


but should say:


inv(j) += b - ((1-x(j)) * w / (h/2)).^0.5;


figure3.jpg shows the same plot using a copy of 'triinv.m' containing the
suggested changes in lines 61 and 65. 

The same considerations also apply to the corresponding lines (74 and 78) in
the subsequent block of code that deals with non-scalar values of a, b and c. 



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Thu 25 Feb 2021 09:23:14 AM UTC  Name: figure2.jpg  Size: 18KiB   By:
None

<http://savannah.gnu.org/bugs/download.php?file_id=50918>
-------------------------------------------------------
Date: Thu 25 Feb 2021 09:23:14 AM UTC  Name: figure3.jpg  Size: 18KiB   By:
None

<http://savannah.gnu.org/bugs/download.php?file_id=50919>
-------------------------------------------------------
Date: Thu 25 Feb 2021 09:23:13 AM UTC  Name: figure1.jpg  Size: 16KiB   By:
None

<http://savannah.gnu.org/bugs/download.php?file_id=50917>

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60113>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]