[Scilab-users] Can Scilab compute the inverse of the regularized Incomplete Beta Function?

classic Classic list List threaded Threaded
9 messages Options
Heinz Nabielek-3 Heinz Nabielek-3
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Can Scilab compute the inverse of the regularized Incomplete Beta Function?

Dear SciLabers:

can Scilab compute the inverse of the regularized Incomplete Beta Function?

Example: in unbiased sampling in Austria with sample size N=1432, they detected n=1 infections.
Therefore, expected infected fraction = 0.000698324.

But this does not say much, because the sample size was small and the "success" was extremely small (fortunately).

The standard procedure therefore is to derive the one-sided 95% upper confidence limit:
CONF=0.95; N=1432; n=1:
One-sided 95% upper confidence limit fraction = BETA.INV(CONF, n+1, N+1-n) = 0.003306121

How would I do that in Scilab?
Heinz

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

Re: Can Scilab compute the inverse of the regularized Incomplete Beta Function?


Heinz,

I don't know if this will serve you, but you cn always approximate the inverse of a function using spline interpolation. If you have y(k) = f(x(k)) fo a range of values of x then you can interpolate the data y(k) x(k) for a value yo to get an xo that approximates finv(yo).

Regards

Federico Miyara
 



On 17/05/2020 18:49, Heinz Nabielek wrote:
Dear SciLabers:

can Scilab compute the inverse of the regularized Incomplete Beta Function?

Example: in unbiased sampling in Austria with sample size N=1432, they detected n=1 infections.
Therefore, expected infected fraction = 0.000698324.

But this does not say much, because the sample size was small and the "success" was extremely small (fortunately).

The standard procedure therefore is to derive the one-sided 95% upper confidence limit:
CONF=0.95; N=1432; n=1:
One-sided 95% upper confidence limit fraction = BETA.INV(CONF, n+1, N+1-n) = 0.003306121

How would I do that in Scilab?
Heinz

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Dang Ngoc Chan, Christophe Dang Ngoc Chan, Christophe
Reply | Threaded
Open this post in threaded view
|

Re: Can Scilab compute the inverse of the regularized Incomplete Beta Function?

Hello,

> De  Heinz Nabielek
> Envoyé : dimanche 17 mai 2020 23:50
>
> CONF=0.95; N=1432; n=1:
> One-sided 95% upper confidence limit fraction = BETA.INV(CONF, n+1, N+1-n)
> = 0.003306121
>
> How would I do that in Scilab?

Would it be :

[X,Y]=cdfbet("XY", n+1, N+1-n, CONF, 1-CONF)
 X  =

   0.0033061
 Y  =

   0.9966939

Regards

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer

General
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Heinz Nabielek-3 Heinz Nabielek-3
Reply | Threaded
Open this post in threaded view
|

Re: Can Scilab compute the inverse of the regularized Incomplete Beta Function?



> On 18.05.2020, at 14:18, Dang Ngoc Chan, Christophe <[hidden email]> wrote:
>
> Hello,
>
>> De  Heinz Nabielek
>> Envoyé : dimanche 17 mai 2020 23:50
>>
>> CONF=0.95; N=1432; n=1:
>> One-sided 95% upper confidence limit fraction = BETA.INV(CONF, n+1, N+1-n)
>> = 0.003306121
>>
>> How would I do that in Scilab?
>
> Would it be :
>
> [X,Y]=cdfbet("XY", n+1, N+1-n, CONF, 1-CONF)
> X  =
>
>   0.0033061


Written with more digits

0.0033061215, and EXCEL finds

0.003306121493. Very good agreement. I am glad I had asked.

And the HELP provides real support with the statement

Description
Calculates any one parameter of the beta distribution given values for the others (The beta density is proportional to t^(A-1) * (1-t)^(B-1).

Since my originating binomial distribution is obviously

        t^n  *  (1-t)^(N-n),

the parameters for the Beta Function have to be

A=n+1
B=N+1-n

to obtain an upper conficende limit fraction = Beta.Inv(CONF, n+1, N+1-n)  !!!

Textbooks write Beta.Inv(CONF, n+1, N-n) since the last 50 years and it is wrong. And "R" is also using this wrong correlation in their binom.test

Great many thanks for all the help.
Heinz

______________
Dr Heinz Nabielek
Schüttelstrasse 77A/11
A-1020 Wien, Österreich
Tel +43 1 276 56 13
cell +43 677 616 349 22
[hidden email]


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Pinçon Bruno Pinçon Bruno
Reply | Threaded
Open this post in threaded view
|

Re: Can Scilab compute the inverse of the regularized Incomplete Beta Function?


  Hi,

 as far I remember, the underlying code is based on a very good

 ACM TOMS (DiDinato, A. R. and Morris,  A.   H.  Algorithm 708: Significant
 Digit Computation of the Incomplete  Beta  Function Ratios.  ACM
 Trans. Math.  Softw. 18 (1993), 360-373).

 Bruno



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Tim Wescott Tim Wescott
Reply | Threaded
Open this post in threaded view
|

Re: Can Scilab compute the inverse of the regularized Incomplete Beta Function?

In reply to this post by Heinz Nabielek-3
So you have \beta(x, n+1, N+1-n) = 0.95, and you want to solve for x?

fsolve will do this for a single value of the confidence.  Is that
sufficient?

On Sun, 2020-05-17 at 23:49 +0200, Heinz Nabielek wrote:

> Dear SciLabers:
>
> can Scilab compute the inverse of the regularized Incomplete Beta
> Function?
>
> Example: in unbiased sampling in Austria with sample size N=1432,
> they detected n=1 infections.
> Therefore, expected infected fraction = 0.000698324.
>
> But this does not say much, because the sample size was small and the
> "success" was extremely small (fortunately).
>
> The standard procedure therefore is to derive the one-sided 95% upper
> confidence limit:
> CONF=0.95; N=1432; n=1:
> One-sided 95% upper confidence limit fraction = BETA.INV(CONF, n+1,
> N+1-n) = 0.003306121
>
> How would I do that in Scilab?
> Heinz
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
>
>
--

Tim Wescott
www.wescottdesign.com
Control & Communications systems, circuit & software design.
Phone: 503.631.7815
Cell:  503.349.8432


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: Can Scilab compute the inverse of the regularized Incomplete Beta Function?

In reply to this post by Heinz Nabielek-3

Hi Heinz,

 

Fyi, the following site provides Matlab code that may be translated to Scilab:

https://people.sc.fsu.edu/~jburkardt/m_src/asa109/asa109.html

betain.m : incomplete Beta function ratio

xinbta.m : inverse of the incomplete Beta function

 

The Scilab Atoms 'Distfun' package contains:

distfun_betainc : Regularized Incomplete Beta function

 

Regards,

Rafael


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Heinz Nabielek-3 Heinz Nabielek-3
Reply | Threaded
Open this post in threaded view
|

Re: Can Scilab compute the inverse of the regularized Incomplete Beta Function?

In reply to this post by Tim Wescott
CONF=.95, N=1432, n=1
cdfbet("XY", n+1, N+1-n, CONF, 1-CONF)

is doing it just fine. Correct and with high precision...
h


On 18.05.2020, at 18:09, Tim Wescott <[hidden email]> wrote:

>
> So you have \beta(x, n+1, N+1-n) = 0.95, and you want to solve for x?
>
> fsolve will do this for a single value of the confidence.  Is that
> sufficient?
>
> On Sun, 2020-05-17 at 23:49 +0200, Heinz Nabielek wrote:
>> Dear SciLabers:
>>
>> can Scilab compute the inverse of the regularized Incomplete Beta
>> Function?
>>
>> Example: in unbiased sampling in Austria with sample size N=1432,
>> they detected n=1 infections.
>> Therefore, expected infected fraction = 0.000698324.
>>
>> But this does not say much, because the sample size was small and the
>> "success" was extremely small (fortunately).
>>
>> The standard procedure therefore is to derive the one-sided 95% upper
>> confidence limit:
>> CONF=0.95; N=1432; n=1:
>> One-sided 95% upper confidence limit fraction = BETA.INV(CONF, n+1,
>> N+1-n) = 0.003306121
>>
>> How would I do that in Scilab?
>> Heinz

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Heinz Nabielek-3 Heinz Nabielek-3
Reply | Threaded
Open this post in threaded view
|

Re: Can Scilab compute the inverse of the regularized Incomplete Beta Function?

In reply to this post by Rafael Guerra
CONF=.95, N=1432, n=1
cdfbet("XY", n+1, N+1-n, CONF, 1-CONF)

is doing it just fine. Correct and with high precision...
h

> On 18.05.2020, at 19:08, Rafael Guerra <[hidden email]> wrote:
>
> Hi Heinz,
>  
> Fyi, the following site provides Matlab code that may be translated to Scilab:
> https://people.sc.fsu.edu/~jburkardt/m_src/asa109/asa109.html
> betain.m : incomplete Beta function ratio
> xinbta.m : inverse of the incomplete Beta function
>  
> The Scilab Atoms 'Distfun' package contains:
> distfun_betainc : Regularized Incomplete Beta function
>  
> Regards,
> Rafael
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users