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
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:
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.
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.
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:
If you know of anything out there I can use, please let me know.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
Thanks!
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?
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
Awesome. Thanks for the update. Care to share the code? Or link to the solution?
Sure, the solution can be found in this thread...
http://www.mrexcel.com/forum/showthr...t=Emulate+Beta
Let me know what you think.
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.
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.
Do you happen to have the solution written in sql server 2008?
That would be very useful.
thanks.
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.
Dason (07-30-2012)
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
Tweet |