bugGNU Octave - Bugs: bug #60113, [octave forge] (statistics)...

 
 

bug #60113: [octave forge] (statistics) Function 'triinv(x, a, b, c)' returns incorrect values

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:  -email is unavailable-
Open/Closed:  Open Release:  5.2.0
Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 05 Mar 2021 07:04:37 PM UTC, comment #4: 

and a script that checks consistency between triinv and tricdf and between tricdf and tripdf

(file #51004, file #51005, file #51006)

A.R. Burgers <arb>
Fri 05 Mar 2021 06:57:55 PM UTC, comment #3: 

an updated changeset that improves both triinv and tripdf.

(file #51003)

A.R. Burgers <arb>
Thu 04 Mar 2021 09:49:27 PM UTC, comment #2: 

The attached changeset b60113.txt takes a step towards fixing tricdf. Certainly better than it was.

(file #50989)

A.R. Burgers <arb>
Thu 25 Feb 2021 01:43:43 PM UTC, comment #1: 

tricdf also seems to have discontinuities and values < 0:

x=linspace(0,10,100);
plot(x,tricdf(x,1,8,3));

A.R. Burgers <arb>
Thu 25 Feb 2021 09:23:13 AM UTC, original submission:  

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.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #51004:  tst_statistics_tri.m added by arb (1KiB - text/plain)
file #51005:  tst_pdf.m added by arb (190B - text/plain)
file #51006:  tst_cdf_inv.m added by arb (160B - text/plain)
file #51003:  b60113_v2.txt added by arb (3KiB - text/plain)
file #50989:  b60113.txt added by arb (1KiB - text/plain)
file #50918:  figure2.jpg added by None (18KiB - image/jpeg)
file #50919:  figure3.jpg added by None (18KiB - image/jpeg)
file #50917:  figure1.jpg added by None (16KiB - image/jpeg)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Updated the item)
  • -email is unavailable- added by arb (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-03-05 arb Attached File- => Added tst_statistics_tri.m, #51004
        Attached File- => Added tst_pdf.m, #51005
        Attached File- => Added tst_cdf_inv.m, #51006
    2021-03-05 arb Attached File- => Added b60113_v2.txt, #51003
    2021-03-04 arb Attached File- => Added b60113.txt, #50989
    2021-03-03 mmuetzel SummaryFunction 'triinv(x, a, b, c)' from 'statistics' package returns incorrect values => [octave forge] (statistics) Function 'triinv(x, a, b, c)' returns incorrect values
    2021-02-25 None Attached File- => Added figure1.jpg, #50917
        Attached File- => Added figure2.jpg, #50918
        Attached File- => Added figure3.jpg, #50919

    Back to the top


    Powered by Savane 3.6