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.

---- calculate net present value of investment ----<br />

DROP TABLE NPV;<br />

CREATE COLUMN TABLE NPV(NPVALUE DOUBLE);<br />

INSERT INTO NPV SELECT <strong>PAL</strong>_CASHFLOW_YEAR1.CASH +<br />

<strong>PAL</strong>_CASHFLOW_YEAR2.CASH/1.05 +<br />

<strong>PAL</strong>_CASHFLOW_YEAR3.CASH/POWER(1.05,2) +<br />

<strong>PAL</strong>_CASHFLOW_YEAR4.CASH/POWER(1.05,3) +<br />

<strong>PAL</strong>_CASHFLOW_YEAR5.CASH/POWER(1.05,4)<br />

FROM <strong>PAL</strong>_CASHFLOW_YEAR1 left join<br />

<strong>PAL</strong>_CASHFLOW_YEAR2 on <strong>PAL</strong>_CASHFLOW_YEAR1.ID =<br />

<strong>PAL</strong>_CASHFLOW_YEAR2.ID<br />

left join <strong>PAL</strong>_CASHFLOW_YEAR3 on <strong>PAL</strong>_CASHFLOW_YEAR1.ID<br />

= <strong>PAL</strong>_CASHFLOW_YEAR3.ID<br />

left join <strong>PAL</strong>_CASHFLOW_YEAR4 on <strong>PAL</strong>_CASHFLOW_YEAR1.ID<br />

= <strong>PAL</strong>_CASHFLOW_YEAR4.ID<br />

left join <strong>PAL</strong>_CASHFLOW_YEAR5 on <strong>PAL</strong>_CASHFLOW_YEAR1.ID<br />

= <strong>PAL</strong>_CASHFLOW_YEAR5.ID;<br />

SELECT * FROM NPV;<br />

The expected result is as follows:<br />

Step 3<br />

Plot the distribution of the net present value of the investment and run Distribution Fitting to fit a normal<br />

distribution to the NPV of the investment as. (The Central Limit theorem states that the output distribution will<br />

be a normal distribution.)<br />

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

------- distribution fit process ---<br />

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

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

CREATE TYPE <strong>PAL</strong>_DISTRFIT_DATA_T AS TABLE(NPVALUE DOUBLE);<br />

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

CREATE TYPE <strong>PAL</strong>_DISTRFIT_ESTIMATION_T AS TABLE(NAME VARCHAR(50),VAL VARCHAR(50));<br />

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

CREATE TYPE <strong>PAL</strong>_DISTRFIT_STATISTICS_T AS TABLE(NAME VARCHAR(50),VAL 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 PDATA_TBL;<br />

CREATE COLUMN TABLE PDATA_TBL("POSITION" INT, "SCHEMA_NAME" NVARCHAR(256),<br />

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

INSERT INTO PDATA_TBL VALUES (1, 'DM_<strong>PAL</strong>','<strong>PAL</strong>_DISTRFIT_DATA_T', 'IN');<br />

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

INSERT INTO PDATA_TBL VALUES (3, 'DM_<strong>PAL</strong>','<strong>PAL</strong>_DISTRFIT_ESTIMATION_T', 'OUT');<br />

INSERT INTO PDATA_TBL VALUES (4, 'DM_<strong>PAL</strong>','<strong>PAL</strong>_DISTRFIT_STATISTICS_T', 'OUT');<br />

call SYS.AFLLANG_WRAPPER_PROCEDURE_DROP('DM_<strong>PAL</strong>','<strong>PAL</strong>_DISTRFIT');<br />

call SYS.AFLLANG_WRAPPER_PROCEDURE_CREATE('AFL<strong>PAL</strong>', 'DISTRFIT',<br />

'DM_<strong>PAL</strong>','<strong>PAL</strong>_DISTRFIT', PDATA_TBL);<br />

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

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

End-to-End Scenarios P U B L I C 563

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

Saved successfully!

Ooh no, something went wrong!