_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › T-SQL襦譴蠏覿襷り鍵

Contents

1 螳螻
2 譴蠏覿 襷
3 蟆郁骸


1 螳螻 #

豌 '蠏碁 襷れ 覲手?'朱 螳朱 襷り鍵襯 . 螻旧 襷蟇 螳 螳螻. float企 蠏碁一 螳 譬 伎. 蠏碁 碁. 轟 譯 襷 譴蠏覿襯 覲企 3.0 蟆曙 0.4987 碁, るゼ ろ覃 0.500623螳 . <;; 覘.. 伎姶 襯企 伎 豢 願 讌 蟾?

2 譴蠏覿 襷 #

DECLARE 
	@x float	-- 覲
,	@mu float	-- 蠏
,	@sigma float	-- 譴ク谿

SET @x = 0.35
SET @mu = 0
SET @sigma = 1;

--SELECT (1/(SQRT(2*PI())*@sigma)) * EXP(-(1/(2*POWER(@sigma,2))) * POWER((@x-@mu), 2))

WITH Dumy(x)
AS
(
        SELECT convert(float, 0) x
        UNION ALL
        SELECT x + 0.01 FROM Dumy
        WHERE x + 0.01 < 3.09
)
/*
SELECT
	ROUND(A.x, 2) x
,	B.Pr Pr
FROM Dumy A
	CROSS APPLY (
	SELECT 
		--蠍郁 譟磯 覦 覿 覿覿企.
		SUM((1/(SQRT(2*PI())*@sigma)) * EXP(-(1/(2*POWER(@sigma,2))) * POWER((x-@mu), 2))) / 100 Pr
	FROM Dumy B
	WHERE x < A.x
) B
WHERE ROUND(A.x, 2) = @x
OPTION (MAXRECURSION 0);
*/
SELECT
	LEFT(x, 3) z
,	MIN(CASE WHEN RIGHT(x, 1) = 0 THEN Pr END) [0.00]
,	MIN(CASE WHEN RIGHT(x, 1) = 1 THEN Pr END) [0.01]
,	MIN(CASE WHEN RIGHT(x, 1) = 2 THEN Pr END) [0.02]
,	MIN(CASE WHEN RIGHT(x, 1) = 3 THEN Pr END) [0.03]
,	MIN(CASE WHEN RIGHT(x, 1) = 4 THEN Pr END) [0.04]
,	MIN(CASE WHEN RIGHT(x, 1) = 5 THEN Pr END) [0.05]
,	MIN(CASE WHEN RIGHT(x, 1) = 6 THEN Pr END) [0.06]
,	MIN(CASE WHEN RIGHT(x, 1) = 7 THEN Pr END) [0.07]
,	MIN(CASE WHEN RIGHT(x, 1) = 8 THEN Pr END) [0.08]
,	MIN(CASE WHEN RIGHT(x, 1) = 9 THEN Pr END) [0.09]
FROM (
	SELECT
		CONVERT(char(4), CONVERT(numeric(36, 2), A.x)) x
	,	CONVERT(numeric(36, 6), ISNULL(B.Pr, 0)) Pr
	FROM Dumy A
		CROSS APPLY (
		SELECT 
			SUM((1/(SQRT(2*PI())*@sigma)) * EXP(-(1/(2*POWER(@sigma,2))) * POWER((x-@mu), 2))) / 100 Pr
		FROM Dumy B
		WHERE x < A.x
	) B
) T
GROUP BY 
	LEFT(x, 3)
ORDER BY 
	LEFT(x, 3)
OPTION (MAXRECURSION 0);

3 蟆郁骸 #

normal_dist.jpg

覘.. 企 蟆郁骸. 豌 瑚磯 z螳 3 蠍磯 0.5襯 伎 覯碁. numeric朱 企至 企慨り 朱, れ float一一朱 覩襦 蠏碁 蠍壱. 蟆郁骸 谿語朱 讌レ企. 糾 豈企 轟 蠏覿襯 覲企 z螳 6豁る覃 蟇一 0.5 蠏殊. 3 蟇一 0.5 蠏殊讌襷 襷企. 伎 3伎 0.5手 覲企 .

襷 蠍一 訖れ朱 蟆郁襯 襾轟朱り る 覈詞企. 企 螳 螳讌 譴蠏覿 襷 . 朱 ロ讌 轟 谿場 れ企 企 Import 襾豪 蟆 譬 蟆企.
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:53

襷 襦蟆 螳讌. 蠏碁覃 蠏碁 襦讌 蟆企.