我在嘗試在Oracle中複製Excel工作簿的功能。在工作表上的公式之一使用CHIDIST,它「返回卡方分佈的單尾概率」。我在任何地方都看不到類似的功能!我將不得不寫我自己的CHIDIST功能?在Oracle 11g中複製Excel的CHIDIST函數
下面就以Excel的文檔的鏈接上CHIDIST:http://office.microsoft.com/en-gb/excel-help/chidist-HP005209010.aspx
我已經摸索出自由的卡方和學位。
感謝
我在嘗試在Oracle中複製Excel工作簿的功能。在工作表上的公式之一使用CHIDIST,它「返回卡方分佈的單尾概率」。我在任何地方都看不到類似的功能!我將不得不寫我自己的CHIDIST功能?在Oracle 11g中複製Excel的CHIDIST函數
下面就以Excel的文檔的鏈接上CHIDIST:http://office.microsoft.com/en-gb/excel-help/chidist-HP005209010.aspx
我已經摸索出自由的卡方和學位。
感謝
右尾概率...好...
在oracle中可以嵌入Java代碼到存儲過程和函數。最好的方法是 使用適當的java類並從oracle的函數中調用它。這並不難:
http://docs.oracle.com/cd/B19306_01/java.102/b14187/chfive.htm http://jwork.org/scavis/api/doc.php/umontreal/iro/lecuyer/probdist/ChiDist.html
這就是我能爲你做:
DECLARE
l_value_to_evaluate NUMBER (10, 3) := 18.307; /* X; Value at which you want to evaluate the distribution */
l_degrees_freedom NUMBER := 10; /* Degrees of freedom */
l_number NUMBER;
FUNCTION is_number(str_in IN VARCHAR2) RETURN NUMBER
IS
n NUMBER;
BEGIN
n := TO_NUMBER(str_in);
RETURN 1;
EXCEPTION
WHEN VALUE_ERROR THEN
RETURN 0;
END;
BEGIN
-- If either argument is nonnumeric, CHIDIST returns the #VALUE! error value.
l_number := is_number(l_value_to_evaluate);
l_number := is_number(l_degrees_freedom);
-- If x is negative, CHIDIST returns the #NUM! error value.
IF SIGN(l_value_to_evaluate) = -1 THEN
RAISE_APPLICATION_ERROR(-20998, '#NUM!');
END IF;
-- If degrees_freedom is not an integer, it is truncated.
l_degrees_freedom := TRUNC(l_degrees_freedom);
-- If degrees_freedom < 1 or degrees_freedom > 10^10, CHIDIST returns the #NUM! error value.
IF l_degrees_freedom < 1
OR l_degrees_freedom > POWER(10, 10) THEN
RAISE_APPLICATION_ERROR(-20997, '#NUM!');
END IF;
-- CHIDIST is calculated as CHIDIST = P(X>x), where X is a χ2 random variable.
/* Here the integral's implementation */
EXCEPTION
WHEN VALUE_ERROR THEN
RAISE_APPLICATION_ERROR(-20999, '#VALUE!');
END;
如果您使用CHIDIST做了卡方檢驗,該STATS_CROSSTAB
功能對於相同的目的可能是不同的方式。它將計算兩組配對觀測的卡方值,重要性或自由度。
嗨,謝謝你的建議!我寧願有一個解決方案,不需要這樣做 - 看起來像創建自己的PLSQL函數一樣簡單。我真的很想知道是否實際上有一種方法可以使用現有的函數在純Oracle SQL中執行此操作。如果不是,那麼我可能不得不實施您的建議或將現有代碼翻譯成PL/SQL。 – user1578653
我會幫你,但我從來沒有實施積分。 –
好吧,我試過了......你可以在我的不完整回覆中找到它... –