Q-ximi
Q-ximi

Reputation: 961

Error: ORA-01428: argument '0' is out of range

I am trying to calculate information gain in SQL. Below is my table:

WORD, INSCALE NOTINSCALE D_FREQ book 22 19 41 reserve 14 16 30

The query is here:

CREATE TABLE FINAL_2INFOGAIN (WORD, INFO_G) AS
SELECT WORD, 
-(17081/33676)*LOG(10,17081/33676)+(D_FREQ/33676)*(INSCALE/D_FREQ)*log(10, INSCALE/D_FREQ)+(NOTINSCALE/33676)*(NOTINSCALE/D_FREQ)*log(10, NOTINSCALE/D_FREQ) AS INFO_G
FROM FINAL_CONTIN2;

It keeps giving me this error:

Error: ORA-01428: argument '0' is out of range 01428. 00000 - "argument '%s' is out of range"'.

The error points to 'D_FREQ' at log(10, NOTINSCALE/D_FREQ).

Can anyone help me figure this out? Thanks.

Upvotes: 1

Views: 12130

Answers (1)

Frank Schmitt
Frank Schmitt

Reputation: 30815

With your example data, this works as expected:

CREATE TABLE FINAL_2INFOGAIN (WORD, INFO_G) AS
WITH final_contin2(word, inscale, notinscale, d_freq) as (
  select 'book', 22, 19, 41 from dual 
  union all
  select 'reserve', 14, 16, 30 from dual
)
SELECT 
  WORD, 
  -(17081/33676)*LOG(10,17081/33676) +
    (D_FREQ/33676)*(INSCALE/D_FREQ)*log(10, INSCALE/D_FREQ) + 
    (NOTINSCALE/33676)*(NOTINSCALE/D_FREQ)*log(10, NOTINSCALE/D_FREQ) AS INFO_G
FROM FINAL_CONTIN2;

The error message you're getting is coming from the call to log - at least one of the rows in your real table FINAL_CONTIN2 contains values for inscale, notinscale and d_freq for which the expression inscale/d_freq resp. notinscale/d_freq becomes either 0 or negative.

Upvotes: 2

Related Questions