25.10.2016 Views

SAP HANA Predictive Analysis Library (PAL)

sap_hana_predictive_analysis_library_pal_en

sap_hana_predictive_analysis_library_pal_en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CREATE COLUMN TABLE <strong>PAL</strong>_CONTROL_TBL(NAME VARCHAR (50),INTARGS INTEGER,DOUBLEARGS<br />

DOUBLE,STRINGARGS VARCHAR (100));<br />

INSERT INTO <strong>PAL</strong>_CONTROL_TBL VALUES ('DISTRIBUTIONNAME', null, null, 'NORMAL');<br />

INSERT INTO <strong>PAL</strong>_CONTROL_TBL VALUES ('OPTIMAL_METHOD', 0, null, null);<br />

DROP TABLE <strong>PAL</strong>_DISTRFIT_ESTIMATION_TBL;<br />

CREATE COLUMN TABLE <strong>PAL</strong>_DISTRFIT_ESTIMATION_TBL(NAME VARCHAR(50),VAL<br />

VARCHAR(50));<br />

DROP TABLE <strong>PAL</strong>_DISTRFIT_STATISTICS_TBL;<br />

CREATE COLUMN TABLE <strong>PAL</strong>_DISTRFIT_STATISTICS_TBL(NAME VARCHAR(50),VAL DOUBLE);<br />

CALL DM_<strong>PAL</strong>.<strong>PAL</strong>_DISTRFIT(NPV, <strong>PAL</strong>_CONTROL_TBL, <strong>PAL</strong>_DISTRFIT_ESTIMATION_TBL,<br />

<strong>PAL</strong>_DISTRFIT_STATISTICS_TBL) with overview;<br />

SELECT * FROM <strong>PAL</strong>_DISTRFIT_ESTIMATION_TBL;<br />

The expected result is as follows:<br />

Step 4<br />

According to the fitted model, run the Cumulative Distribution function to obtain the probability of having an<br />

NPV of investment smaller than or equal to a given NPV of the investment.<br />

---------------------------------------<br />

----distribution probability process --<br />

---------------------------------------<br />

DROP TYPE <strong>PAL</strong>_DISTRPROB_DATA_T;<br />

CREATE TYPE <strong>PAL</strong>_DISTRPROB_DATA_T AS TABLE(DATACOL DOUBLE);<br />

DROP TYPE <strong>PAL</strong>_DISTRPROB_DISTRPARAM_T;<br />

CREATE TYPE <strong>PAL</strong>_DISTRPROB_DISTRPARAM_T AS TABLE(NAME VARCHAR(50),VALUEE<br />

VARCHAR(50));<br />

DROP TYPE <strong>PAL</strong>_DISTRPROB_RESULT_T;<br />

CREATE TYPE <strong>PAL</strong>_DISTRPROB_RESULT_T AS TABLE(INPUTDATA DOUBLE,PROBABILITY DOUBLE);<br />

DROP TYPE <strong>PAL</strong>_CONTROL_T;<br />

CREATE TYPE <strong>PAL</strong>_CONTROL_T AS TABLE(NAME VARCHAR (50),INTARGS INTEGER,DOUBLEARGS<br />

DOUBLE,STRINGARGS VARCHAR (100));<br />

DROP TABLE <strong>PAL</strong>_DISTRPROB_PDATA_TBL;<br />

CREATE COLUMN TABLE <strong>PAL</strong>_DISTRPROB_PDATA_TBL("POSITION" INT, "SCHEMA_NAME"<br />

NVARCHAR(256), "TYPE_NAME" NVARCHAR(256), "PARAMETER_TYPE" VARCHAR(7));<br />

INSERT INTO <strong>PAL</strong>_DISTRPROB_PDATA_TBL VALUES (1, 'DM_<strong>PAL</strong>','<strong>PAL</strong>_DISTRPROB_DATA_T',<br />

'IN');<br />

INSERT INTO <strong>PAL</strong>_DISTRPROB_PDATA_TBL VALUES (2, 'DM_<strong>PAL</strong>',<br />

'<strong>PAL</strong>_DISTRPROB_DISTRPARAM_T', 'IN');<br />

INSERT INTO <strong>PAL</strong>_DISTRPROB_PDATA_TBL VALUES (3, 'DM_<strong>PAL</strong>','<strong>PAL</strong>_CONTROL_T', 'IN');<br />

INSERT INTO <strong>PAL</strong>_DISTRPROB_PDATA_TBL VALUES (4,<br />

'DM_<strong>PAL</strong>','<strong>PAL</strong>_DISTRPROB_RESULT_T', 'OUT');<br />

CALL SYS.AFLLANG_WRAPPER_PROCEDURE_DROP('DM_<strong>PAL</strong>','<strong>PAL</strong>_DISTRPROB_PROC');<br />

CALL SYS.AFLLANG_WRAPPER_PROCEDURE_CREATE('AFL<strong>PAL</strong>', 'DISTRPROB',<br />

'DM_<strong>PAL</strong>','<strong>PAL</strong>_DISTRPROB_PROC', <strong>PAL</strong>_DISTRPROB_PDATA_TBL);<br />

DROP TABLE <strong>PAL</strong>_DISTRPROB_DATA_TBL;<br />

CREATE TABLE <strong>PAL</strong>_DISTRPROB_DATA_TBL LIKE <strong>PAL</strong>_DISTRPROB_DATA_T;<br />

INSERT INTO <strong>PAL</strong>_DISTRPROB_DATA_TBL VALUES (7000);<br />

INSERT INTO <strong>PAL</strong>_DISTRPROB_DATA_TBL VALUES (8000);<br />

INSERT INTO <strong>PAL</strong>_DISTRPROB_DATA_TBL VALUES (9000);<br />

INSERT INTO <strong>PAL</strong>_DISTRPROB_DATA_TBL VALUES (10000);<br />

INSERT INTO <strong>PAL</strong>_DISTRPROB_DATA_TBL VALUES (11000);<br />

DROP TABLE <strong>PAL</strong>_DISTRPROB_DISTRPARAM_TBL;<br />

CREATE TABLE <strong>PAL</strong>_DISTRPROB_DISTRPARAM_TBL LIKE <strong>PAL</strong>_DISTRPROB_DISTRPARAM_T;<br />

INSERT INTO <strong>PAL</strong>_DISTRPROB_DISTRPARAM_TBL VALUES ('DISTRIBUTIONNAME', 'Normal');<br />

INSERT INTO <strong>PAL</strong>_DISTRPROB_DISTRPARAM_TBL VALUES ('MEAN', '100');<br />

INSERT INTO <strong>PAL</strong>_DISTRPROB_DISTRPARAM_TBL VALUES ('VARIANCE', '1');<br />

564 P U B L I C<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Predictive</strong> <strong>Analysis</strong> <strong>Library</strong> (<strong>PAL</strong>)<br />

End-to-End Scenarios

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!