+ Reply to Thread
Results 1 to 14 of 14

Thread: Cumulative Beta Distribution Function Help

  1. #1
    Points: 2,616, Level: 31
    Level completed: 11%, Points required for next Level: 134

    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Cumulative Beta Distribution Function Help




    Hi everyone,

    I was wondering if someone could help me figure out how this function works. My problem is not that I need homework help, it's that I've never done any stats homework! So, I'm absolutely clueless.

    My problem is that I've been using the BETADIST function in a Microsoft Excel worksheet, and now I'm creating an application program in another programming language that doesn't have access to the BETADIST function, so I, in essence, need to recreate that function. And, in order to do that, I need to know what it's doing behind the scenes.

    So, in Excel, I type in the function "=BETADIST(0.2, 1.57, 2, 0, 1)", and it gives me the value 0.1803. From reading about this function in Excel, the BETADIST function returns the cumulative beta probability density function, and is in the following format:

    =BETADIST (x, alpha, beta, lower bound to x, upper bound to x), where, in my example, x = 0.2, alpha = 1.57, beta = 2, lower bound = 0, and upper bound = 1.

    So, assuming I have my values of x, alpha, beta, and lower bound is always 0 and upper bound is always 1, how can I derive that value of 0.1803?

    I've looked on wikipedia at the formulas, and they are absolute greek to me, so I need a good lesson, if anybody would be willing to give me one. Can anyone help illustrate for me how that BETADIST function derived the value of 0.1803, given x = 0.2, alpha = 1.57, and beta = 2?

    Many thanks in advance,
    Mark

  2. #2
    Super Moderator
    Points: 13,151, Level: 74
    Level completed: 76%, Points required for next Level: 99
    Dragan's Avatar
    Location
    Illinois, US
    Posts
    2,014
    Thanks
    0
    Thanked 223 Times in 192 Posts

    Re: Cumulative Beta Distribution Function Help

    Quote Originally Posted by idkstats14 View Post
    Hi everyone,

    how that BETADIST function derived the value of 0.1803, given x = 0.2, alpha = 1.57, and beta = 2?

    Many thanks in advance,
    Mark

    Like this:

    f\left ( x \right )=\frac{\left ( 1-x \right )^{\beta -1}x^{\alpha -1}\Gamma \left ( \alpha +\beta  \right )}{\Gamma \left ( \alpha  \right )\Gamma \left ( \beta  \right )}

    and then integrate:

    \int_{0}^{0.2}f\left ( x \right )dx=0.180283....

  3. #3
    Points: 2,616, Level: 31
    Level completed: 11%, Points required for next Level: 134

    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Cumulative Beta Distribution Function Help

    Hi Dragan,

    Thank you so much for your reply with the appropriate formulas to use. I’m trying to work it out, but I haven’t done calculus, trig, algebra, or whatever that is in 15 years… ha ha!

    And to further illustrate how little I know about that formula, I had to look up what the “half T” was and found that it was the symbol for the Greek letter Gamma, which I assume represents the gamma function?

    Please bear with me, as I really have no idea how to do an integral or any of this stuff. So, if you could help walk me through it, I’d really appreciate it. Here’s how far I’ve been able to get:

    f\left ( 0.2\right )=\frac{\left (0.8\right )1.4845 \Gamma \left (3.57 \right )}{\Gamma \left (1.57 \right ) \Gamma \left (2 \right )}

    First off, is that correct so far? And if so, what steps should I take next? Sorry my response took so long, but it took me awhile to figure out how to write the equation in a postable format... then I discovered the [math] tags. I'm learning all kinds of new things!

    Thanks again for your help.

  4. #4
    Devorador de queso
    Points: 95,781, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Posting AwardCommunity AwardDiscussion EnderFrequent Poster
    Dason's Avatar
    Location
    Tampa, FL
    Posts
    12,933
    Thanks
    307
    Thanked 2,629 Times in 2,245 Posts

    Re: Cumulative Beta Distribution Function Help

    It's great that you want to program this yourself and all. However it's not the easiest task. You mention that you're using another programming language but you don't mention which one. It's very likely that there is already a library you could call that would give you what you're looking for already.

    No use in reinventing the wheel.

  5. #5
    Points: 2,616, Level: 31
    Level completed: 11%, Points required for next Level: 134

    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Cumulative Beta Distribution Function Help

    Sorry about that, I'll be happy to provide some additional details about my application and would certainly be up for using a library or some other method to get the right answer if I can find one or if you know of one I can use. Problem is, I haven't been able to find one yet.

    My application is developed using Oracle Application Express 4.0.0.00.46 and uses an Oracle 10g database (10.2.0.4.0), which uses PL/SQL as its programming language. I think the BETADIST libraries are accessible using VB, C++, C#, or some other Microsoft programming language, but I haven't been able to find out how to access anything like those with Oracle. The two don't usually play well together.

    And, the only Oracle function I've found that remotely comes close is the CUME_DIST() function, which calculates the cumulative distribution of a value in a group of values. It gives me results like the following, which I'm not sure if it relates to what I'm trying to find:

    Code: 
    Year - Value - Cume_Dist
    5       300    1.000
    6       170    0.833
    2       150    0.667
    3       130    0.500
    1       100    0.333
    4       70     0.167
    If you know of anything out there I can use, please let me know.

    Thanks!

  6. #6
    Devorador de queso
    Points: 95,781, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Posting AwardCommunity AwardDiscussion EnderFrequent Poster
    Dason's Avatar
    Location
    Tampa, FL
    Posts
    12,933
    Thanks
    307
    Thanked 2,629 Times in 2,245 Posts

    Re: Cumulative Beta Distribution Function Help

    I guess I can't help you there. If it was a different language I might be to help. Is there a built in numerical integration function or would you have to program that yourself? Does it have the Gamma function available to you?

  7. #7
    Points: 2,616, Level: 31
    Level completed: 11%, Points required for next Level: 134

    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Cumulative Beta Distribution Function Help

    Just wanted to provide an update to this thread. Someone was able to provide me with some Visual Basic code on an Excel message board that replicated the BETADIST() function in Excel, and I was able to convert that code into Oracle PL/SQL, and it works perfectly!

    Thanks again for everyone's help,
    Mark

  8. #8
    Devorador de queso
    Points: 95,781, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Posting AwardCommunity AwardDiscussion EnderFrequent Poster
    Dason's Avatar
    Location
    Tampa, FL
    Posts
    12,933
    Thanks
    307
    Thanked 2,629 Times in 2,245 Posts

    Re: Cumulative Beta Distribution Function Help

    Awesome. Thanks for the update. Care to share the code? Or link to the solution?

  9. #9
    Points: 2,616, Level: 31
    Level completed: 11%, Points required for next Level: 134

    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Cumulative Beta Distribution Function Help

    Sure, the solution can be found in this thread...

    http://www.mrexcel.com/forum/showthr...t=Emulate+Beta

    Let me know what you think.

  10. #10
    Devorador de queso
    Points: 95,781, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Posting AwardCommunity AwardDiscussion EnderFrequent Poster
    Dason's Avatar
    Location
    Tampa, FL
    Posts
    12,933
    Thanks
    307
    Thanked 2,629 Times in 2,245 Posts

    Re: Cumulative Beta Distribution Function Help

    Looks like you have to implement the numeric integration yourself then eh? It's not that big of a pain but that's why I was asking about it before because it's basically all integration.

  11. #11
    Points: 2,616, Level: 31
    Level completed: 11%, Points required for next Level: 134

    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Cumulative Beta Distribution Function Help

    Yep, to answer your question from before... There aren't any built-in integration or Gamma functions in Oracle, so the whole thing had to basically be written. Although, I did find some Java libraries that could have been called from Oracle and might have helped. But, that was after I got this working... So, I think I'll just use this... ha ha! I like having it this way, anyway. Seeing the entire function helps me understand it better, and I can tweak whatever I want, if the need arises.

  12. #12
    Points: 17, Level: 1
    Level completed: 33%, Points required for next Level: 33

    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cumulative Beta Distribution Function Help

    Do you happen to have the solution written in sql server 2008?

    That would be very useful.

    thanks.

  13. #13
    Points: 2,616, Level: 31
    Level completed: 11%, Points required for next Level: 134

    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Cumulative Beta Distribution Function Help

    Sorry, but I have not written a solution for MS SQL Server 2008. In one of my posts below, you'll find a link to the MrExcel forum where I posted the approximate solution in Oracle PL/SQL. There is also an approximate solution in that forum for MS VBA. You can derive the logic from each of those and translate into SQL Server.

    Or, also in the MrExcel forum, there's a link to an Oracle forum where a Java library is available that computes this function. I actually ended up installing that Java library and using it. Although I don't know how to set it up, I'm pretty sure Java can be utilized by MS SQL Server 2008 as well, so I would suggest installing that Java library and calling the function from there.

    Thanks.

  14. The Following User Says Thank You to idkstats14 For This Useful Post:

    Dason (07-30-2012)

  15. #14
    Points: 2, Level: 1
    Level completed: 3%, Points required for next Level: 48

    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cumulative Beta Distribution Function Help


    Hi idkstats14,

    Your post could be a saver for me...can you pls help me with the code you came up with for the Oracle PL/SQL code for the calculus equivalent? I am having a tough time since I need to implement the P value formula in an Oracle/ Pl-sql solution.

    P Value = [ 1/ ( (√df) Β(1/2,df/2) ) ] lt->-t to t ∫ ( 1+ x²/df)(-(v+1)/2) .dx
    Where df = degrees of freedom x = T-Value

    Your help is MOST APPRECIATED!
    Thanks

+ Reply to Thread

           




Similar Threads

  1. Cumulative distribution function?
    By a7890 in forum Statistics
    Replies: 1
    Last Post: 03-18-2011, 05:18 PM
  2. cumulative distribution function for error
    By hammid1981 in forum Probability
    Replies: 9
    Last Post: 03-04-2011, 12:06 AM
  3. Cumulative Distribution Function
    By statjunior in forum Probability
    Replies: 8
    Last Post: 10-26-2010, 01:37 AM
  4. Replies: 5
    Last Post: 09-27-2010, 06:34 AM
  5. Cumulative distribution function help!
    By knighty in forum Probability
    Replies: 1
    Last Post: 03-16-2009, 12:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts






Advertise on Talk Stats