From: Tim on
Here is a pretty close version I wrote in T/SQL:

create function normdist(@value float,
@mean float,
@sigma float,
@cummulative bit)
returns numeric(12,2)
begin

declare @x float
declare @z float
declare @t float
declare @ans float
declare @returnvalue float


select @x = (@value-(a)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*@z-1.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-(a)ans
end
else
begin
select @cummulative = exp(-@x*@x/2.0)/sqrt(2.0*3.14159265358979)
end

return cast(@returnvalue * 100 as numeric(12,2))

end




J wrote:

NORMDIST(X, mean, Standard_Dev,True) in SQL 2005?
25-Oct-07

Hi,

In Excel I can find the normal distribution with the formula:

=NORMDIST(x, mean, standard dev, cumulative)

How is this done in SQL 2005? I am having a difficult time finding this on
the web so hopefully someone can assist me with this or at least point me in
the right direction.

Thank you in advance for your help.

All the best,

JC

Previous Posts In This Thread:

On Thursday, October 25, 2007 11:21 AM
J wrote:

NORMDIST(X, mean, Standard_Dev,True) in SQL 2005?
Hi,

In Excel I can find the normal distribution with the formula:

=NORMDIST(x, mean, standard dev, cumulative)

How is this done in SQL 2005? I am having a difficult time finding this on
the web so hopefully someone can assist me with this or at least point me in
the right direction.

Thank you in advance for your help.

All the best,

JC

On Thursday, October 25, 2007 11:46 AM
Russell Fields wrote:

JC,SQL Server implements functions like this through Analysis Services.
JC,

SQL Server implements functions like this through Analysis Services. Here
is an Excel / SQL Server page for SQL Server 2000.
http://msdn2.microsoft.com/en-us/library/aa178231(SQL.80).aspx

RLF


Submitted via EggHeadCafe - Software Developer Portal of Choice
Six Free Visual Studio 2010 MSDN Memberships Giveaway
http://www.eggheadcafe.com/tutorials/aspnet/f7338bb9-7fa4-4fa8-9e5a-244857b0d9d4/six-free-visual-studio-2010-msdn-memberships-giveaway.aspx