Oracle - FUNCION DISTRIBUCION ESTANDAR ACUMULADA

 
Vista:

FUNCION DISTRIBUCION ESTANDAR ACUMULADA

Publicado por MARIA SANCHEZ (1 intervención) el 27/11/2018 22:26:09
Hola a todos.


Mi consulta es la siguiente.
En excel existe la funcion DISTR.NORM.ESTAND la cual calcula la distribucion estandar acumulada para un numero. Por ejemplo: DISTR.NORM.ESTAND(0,546) = 0,7136.

Estoy buscando la correspondiente función o programa en oracle que me permita obtener el mismo resultado.
En la literatura encuentro la función CUME_DIST pero esta me retorna un valor con base en una tabla con datos que debo tener en mi base.
Pero en el caso de la formula en excel, solo se le da un parámetro y el retorna el valor de la distribución acumulada.

Y eso es precisamente lo que se requiere.
Se que una alternativa es subir las tablas de probabilidades, pero estos son datos discretos, y el resultado no sería exacto para todos los casos.
En cambio excel lo trabaja de manera exacta para cualquier número.

Si excel tiene esta fórmula tan exacta, como es posible que no la tenga Oracle?
Quizás lo que necesito son unos consejos de como implementarla.

Les agradezco la ayuda que puedan darme y gracias por su amable atención.

Saludos
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 499
Oro
Ha mantenido su posición en Oracle (en relación al último mes)
Gráfica de Oracle

FUNCION DISTRIBUCION ESTANDAR ACUMULADA

Publicado por Rafael (328 intervenciones) el 28/11/2018 09:49:35
Hola, Maria:

Un par de anotaciones, que seguro entenderas por que veo conoces del tema:

Excel, es una HOJA DE CALCULO, pensada para HACER CALCULOS.
Oracle, es un MANEJADOR de BASE de DATOS, pensado para Contener DATOS.

Luego esta pequeña diferenciacion hace que uno haga unas cosas para las que esta pensado y otro no, asi como EXCEL NO puede contener ni manejar MILES DE MILLONES de datos, ORACLE esta limitado en su funcionalidad de Cálculo... por que cada quien esta diseñado para distintas cosas....

Espero esto responda a tu pregunta:
¿Si excel tiene esta fórmula tan exacta, como es posible que no la tenga Oracle?

Ahora bien a tu problema inicial ...
Tu en EXCEL estas usando la funcion: DISTR.NORM.ESTAND
Que a razon lo que realiza es:
Devuelve la función de distribución normal estándar acumulativa. La distribución tiene una media de 0 (cero) y una desviación estándar de uno. Use esta función en lugar de una tabla estándar de áreas de curvas normales.

Y quieres sustitur en Oracle por CUME_DIST
Que a razon hace:
CUME_DIST calculates the cumulative distribution of a value in a group of values. The range of values returned by CUME_DIST is >0 to <=1. Tie values always evaluate to the same cumulative distribution value.

This function takes as arguments any numeric datatype or any nonnumeric datatype that can be implicitly converted to a numeric datatype. Oracle Database determines the argument with the highest numeric precedence, implicitly converts the remaining arguments to that datatype, makes the calculation, and returns NUMBER.

De primeras como puedes observar NO es una distribucion NORMAL, NI la desviacion estandar... y trabaja en un grupo de valores. Que en el caso de EXCEL ya te han dicho que estas sustituyendo en lugar de una tabla estandar de areas de curvas normales...

Luego entonces NO la puedes usar igual por que lo que te devuelve una y otra son cosas distintas.....

Oracle cuenta con estas funciones estadisticas:
CORR(expr1, expr2) OVER(analytic_clause)
CORR returns the coefficient of correlation of a set of number pairs. You can use it as an aggregate or analytic function.
COVAR_POP(expr1, expr2) OVER(analytic_clause)
COVAR_POP returns the population covariance of a set of number pairs. You can use it as an aggregate or analytic function.
COVAR_SMP(expr1, expr2) OVER(analytic_clause)
COVAR_SAMP returns the sample covariance of a set of number pairs. You can use it as an aggregate or analytic function.
CUME_DIST(expr) WITHIN GROUP(ORDER BY expr ASC|DESC NULLS FIRST|LAST)
CUME_DIST calculates the cumulative distribution of a value in a group of values. The range of values returned by CUME_DIST is >0 to <=1. Tie values always evaluate to the same cumulative distribution value.
PERCENT_RANK(expr) WITHIN GROUP(ORDER BY expr ASC|DESC NULLS FIRST|LAST)
The PERCENT_RANK function is similar to the CUME_DIST (cumulative distribution) function. The range of values returned by PERCENT_RANK is 0 to 1, inclusive. The first row in any set has a PERCENT_RANK of 0.
PERCENTILE_CONT(expr) WITHIN GROUP(ORDER BY expr ASC|DESC)
The PERCENTILE_CONT function is an inverse distribution function that assumes a continuous distribution model. It takes a percentile value and a sort specification, and returns an interpolated value that would fall into that percentile value with respect to the sort specification. Nulls are ignored in the calculation.
PERCENTILE_DISC(expr) WITHIN GROUP(ORDER BY expr ASC|DESC)
The PERCENTILE_DISC function is an inverse distribution function that assumes a discrete distribution model. It takes a percentile value and a sort specification and returns an element from the set. Nulls are ignored in the calculation.
REGR_AVGX(expr1, expr2) OVER(analytic_clause)
REGR_AVGX evaluates the average of the independent variable (expr2) of the regression line. It makes the following computation after the elimination of null (expr1, expr2) pairs: AVG(expr2)
REGR_AVGY(expr1, expr2) OVER(analytic_clause)
REGR_AVGY evaluates the average of the dependent variable (expr1) of the regression line. It makes the following computation after the elimination of null (expr1, expr2) pairs: AVG(expr1)
STDDEV([DISTINCT | ALL] n)
Determines the standard deviation, the square root of the variance, of the values in a column. See COUNT for usage of DISTINCT
STDDEV_POP(expr) OVER(analytic_clause)
STDDEV_POP computes the population standard deviation and returns the square root of the population variance. You can use it as both an aggregate and analytic function.
STDDEV_SAMP(expr) OVER(analytic_clause)
STDDEV_SAMP computes the cumulative sample standard deviation and returns the square root of the sample variance. You can use it as both an aggregate and analytic function.
VAR_POP(expr) OVER(analytic_clause)
VAR_POP returns the population variance of a set of numbers after discarding the nulls in this set. You can use it as both an aggregate and analytic function.
VAR_SAMP(expr) OVER(analytic_clause)
VAR_SAMP returns the sample variance of a set of numbers after discarding the nulls in this set. You can use it as both an aggregate and analytic function.
VARIANCE( [DISTINCT | ALL] n)
Determines the variance of the values in a column. See COUNT for usage of DISTINCT

Para el resto ... las tienes que realizar tu ...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 499
Oro
Ha mantenido su posición en Oracle (en relación al último mes)
Gráfica de Oracle

FUNCION DISTRIBUCION ESTANDAR ACUMULADA

Publicado por Rafael (328 intervenciones) el 28/11/2018 10:05:07
Maria:

Investigando un poco mas ...
Me he encontrado con esto, que puedes crear en ORACLE

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
create or replace function normal_distribution (x BINARY_DOUBLE)
  RETURN BINARY_DOUBLE
AS
  b1 BINARY_DOUBLE := 0.319381530;
  b2 BINARY_DOUBLE := -0.356563782;
  b3 BINARY_DOUBLE := 1.781477937;
  b4 BINARY_DOUBLE := -1.821255978;
  b5 BINARY_DOUBLE := 1.330274429;
  p BINARY_DOUBLE  := 0.2316419;
  c BINARY_DOUBLE  := 0.39894228;
  t BINARY_DOUBLE;
BEGIN
  IF(x >= 0.0) THEN
    t  := 1.0   / ( 1.0 + p * x );
    RETURN (1.0 - c * exp( -x * x / 2.0 ) * t * ( t *( t * ( t * ( t * b5 + b4
    )           + b3 ) + b2 ) + b1 ));
  ELSE
    t := 1.0   / ( 1.0 - p * x );
    RETURN ( c * exp( -x * x / 2.0 ) * t * ( t *( t * ( t * ( t * b5 + b4 ) +
    b3 )       + b2 ) + b1 ));
  END IF;
END;
/

De tal modo que tu puedas realizar una operacion de este tipo:
1
select normal_distribution(0.546) from dual;

El resultado seria:
1
2
3
NORMAL_DISTRIBUTION(0.546)
--------------------------
0,7074670619308966

Vaya aproximadamente el mismo que te devuelve EXCEL... que cuando menos a mi me ha devuelto
0,70746703139554000000


Saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar