Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
TSQL (SS2K5)
»
Is there an equivalent of Excel's NORMDIST...
Is there an equivalent of Excel's NORMDIST function in SQL Server 2005?
Rate Topic
Display Mode
Topic Options
Author
Message
L Cerniglia
L Cerniglia
Posted Monday, August 9, 2010 7:55 AM
Grasshopper
Group: General Forum Members
Last Login: Wednesday, December 10, 2014 7:54 AM
Points: 24,
Visits: 312
Is there an equivalent of Excel's NORMDIST function in SQL Server 2005?
Post #965963
Sean Lange
Sean Lange
Posted Monday, August 9, 2010 9:01 AM
SSChampion
Group: General Forum Members
Last Login: Yesterday @ 2:05 PM
Points: 13,327,
Visits: 12,820
Nothing right out of the box that i know of. You will probably have to write your own. (or borrow somebody else's)
_______________________________________________________________
Need help? Help us help you.
Read the article at
http://www.sqlservercentral.com/articles/Best+Practices/61537/
for best practices on asking questions.
Need to split a string? Try Jeff Moden's
splitter
.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2  Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #966025
L Cerniglia
L Cerniglia
Posted Friday, August 13, 2010 6:31 AM
Grasshopper
Group: General Forum Members
Last Login: Wednesday, December 10, 2014 7:54 AM
Points: 24,
Visits: 312
If it helps anyone, this is how my function looks like. Thanks again to all who helped me.
CREATE FUNCTION [dbo].[udf_NORMDIST](@value FLOAT,
@mean FLOAT,
@sigma FLOAT,
@cummulative BIT)
RETURNS NUMERIC(28,8)
AS
/****************************************************************************************
NAME: udf_NORMDIST
WRITTEN BY: Tim Pickering
http://www.eggheadcafe.com/software/aspnet/31021839/normdistxmeanstandarddevtrueinsql2005.aspx
DATE: 2010/07/13
PURPOSE: Mimics Excel's Function NORMDIST
Usage: SELECT dbo.udf_NORMDIST(.48321740,0,1,0)
OUTPUT: 0.35498205
REVISION HISTORY
Date Developer Details
2010/08/11 LC Posted Function
*****************************************************************************************/
BEGIN
DECLARE @x FLOAT
DECLARE @z FLOAT
DECLARE @t FLOAT
DECLARE @ans FLOAT
DECLARE @returnvalue FLOAT
SELECT @x = (@value@mean)/@sigma
IF (@cummulative = 1)
BEGIN
SELECT @z = abs(@x)/sqrt(2.0)
SELECT @t = 1.0/(1.0+0.5*@z)
SELECT @ans = @t*exp(@z*@z1.26551223+@t*(1.00002368+@t*(0.37409196+@t*(0.09678418+@t*(0.18628806+@t*(0.27886807+@t*(1.13520398+@t*(1.48851587+@t*(0.82215223+@t*0.17087277)))))))))/2.0
IF (@x <= 0)
SELECT @returnvalue = @ans
ELSE
SELECT @returnvalue = 1@ans
END
ELSE
BEGIN
SELECT @returnvalue = exp(@x*@x/2.0)/sqrt(2.0*3.14159265358979)
END
RETURN CAST(@returnvalue AS NUMERIC(28,8))
END
Post #968851
idea
idea
Posted Wednesday, September 12, 2012 8:15 PM
Forum Newbie
Group: General Forum Members
Last Login: Wednesday, September 12, 2012 8:45 PM
Points: 1,
Visits: 4
Out of the box there is no equivalent in SQL Server (up to 2012) for NORMDIST.
NORMDIST computes the Normal Distribution PDF (Probability Density Function) when the cumulative parameter is false and the CDF (Cumulative Distribution Function) otherwise.
The PDF can be computed from the definition and is pretty straight forward, the CDF however has no close form and can only be approximated.
I've developed a function for the PDF and a set of functions using different approximations for the CDF.
You can read my analysis in:
http://formaldev.blogspot.com.au/2012/09/TSQLNORMDIST1.html
and either copy paste the ones you want from the posts or get them from the project page for the blog posts at:
https://tsqlnormdist.codeplex.com/
Post #1358295
« Prev Topic

Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 20022014 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.