Showing posts with label HP 14B. Show all posts
Showing posts with label HP 14B. Show all posts

Saturday, June 22, 2024

Curve Fitting: Adjusting Data Points (feat. HP 14B and HP Prime)

 Curve Fitting: Adjusting Data Points


Graphs are generated with the HP Prime emulator software.



A Curve Fitting Problem


Problem:


We have an investment project, which at the beginning will cost us 50,000 (insert the currency of your choice). Through analysis, the projected cash flows at the beginning of each term are shown here:



Period (beginning of)

Cash Flow

1

-50000

2

-3000

3

9000

4

16000

5

18000

6

21000


What is the projected cash flow at the beginning of period 7?


We could easily use linear regression, but the problem is, the data itself does not easily fit a line. So we can just use another regression model and that’s simple, right? Not quite, since two of the cash flows are negative.


Approach


Most calculators have at least the following curve fitting regressions:


Model

Transformed

X’ =

Y’ =

True B =

Linear

Y = B + M * X

Y = B + M * X

X

Y

B

Exponential

Y = B * exp(M *X)

ln(Y) = ln(B) + M * X

X

ln(Y)

exp(B)

Logarithmic

Y = B + M * ln(X)

Y = B + M * ln(X)

ln(X)

Y

B

Power

Y = B * X^M

ln(Y) = ln(B) + M * ln(X)

ln(X)

ln(Y)

exp(B)


A lot of them rely on a transition of data to use a translated linear regression model. After the parameters slope (M) and y-intercept (B) are calculated, any adjustments are made to find the correct curve fitting parameters.


The statistical calculations operate on real numbers. If we try to fit an exponential, logarithmic, or power fit on data with non-positive numbers, we are going to have a problem because the natural logarithmic function returns non-real numbers in the transition process.


Still the data does not fit a linear regression line as good as the other regression curves. This calls for an adjustment of data. In essence, we are going to subtract out the minimum value of either the x or y data, or both “minus one”. Conceptually:


If min(X) ≤ 0, then:

P = min(X) -1

X_adj = X – P


If min(Y) ≤ 0, then:

Q = min(Y) -1

Y_adj = Y – Q


Why the “minus 1”?


If we only subtract the minimum, the lowest adjust amount would be 0. But ln(0) approaches negative infinity, which most calculators would not work with.


If we subtract the minimum minus one, the lowest adjusted amount would be 1. ln(1) =0. Beautiful!


Example: Adjusting the Raw Data


Raw data:

X

Y

1

-50000

2

-3000

3

9000

4

16000

5

18000

6

21000


min(X) = 1 > 0. No adjustment is needed.

min(Y) = -50000 ≤ 0. An adjustment is needed.


Let Q = min(Y) – 1 = -50000 – 1 = -50001


Adjusted data:


X

Y

Y’ = Y – Q

ln(Y’) (fix 3)

1

-50000

1

0

2

-3000

47001

10.758

3

9000

59001

10.985

4

16000

66001

11.097

5

18000

68001

11.127

6

21000

71001

11.170


Let’s fit the adjusted curve.


Keep in mind that:


Y’ = Y – Q

Y’ = Y - -50001

Y’ = Y + 50001

Y = Y’ – 50001





Fitting the Curve


Determine which one of the four regressions: linear, exponential, logarithmic, or power bets fits the adjusted data points. Predict the actual revenue (Y) for period 7.


Here is the data. We are going to use the data sets X and Y’.



X

Y

Y’ = Y – Q , (Q = -50001)

1

-50000

1

2

-3000

47001

3

9000

59001

4

16000

66001

5

18000

68001

6

21000

71001


Correlation Coefficients:


Model

Correlation (fix 4)

Linear

0.8477

Exponential

0.6772

Logarithmic

0.9520

Power

0.8290


Calculations were made with a HP 14B calculator. The best fit has absolute value of the correlation closest to 1. Correlations near -1 or +1 are better than correlations near 0.


The best fit is the logarithmic fit. Hence the curve fit is:


Y’ ≈ 9618.6378 + 38498.9034 * ln(X)





Remember that Y’ = Y + 50001. Then:


Y + 50001 ≈ 9618.6378 + 38498.9034 * ln(X)

Y ≈ -40382.3262 + 38498.9034 * ln(X)


To predict for X = 7:

Y ≈ -40382.3262 + 38498.9034 * ln(7)

Y ≈ 34533.0807


The beginning of period 7 will have the project cash flow of about $34,533.



Eddie


All original content copyright, © 2011-2024. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Monday, January 16, 2023

Retro Review: Hewlett Packard HP 14B 50th Anniversary Edition

Retro Review:  Hewlett Packard HP 14B 50th Anniversary Edition







Quick Facts


Model:  HP 14B 50th Anniversary Edition 

Company:  Hewlett Packard

Years:  1989 (and probably 1990)

Type:  Finance

Batteries: 3 x LR44, SR44, AR76

Display:  1 line, alpha-numeric, 12 characters

Original Price:  $50, originally available only to Hewlett Packard's shareholders and employees 

Operating System:  Chain 



Features


*  Time Value of Money with Amortization.  Like all the HP financial calculators, the compute key is not used to calculate values.   The interest register is based on annual interest, while payments per year (P/YR) is a setting.  Beginning and ending of period payment modes are present.  


*  Cash Flows:  NPV and IRR.  These worksheets store the cash flow and make use the COMPUTE function to calculate NPV and IRR.  NPV is stored in PV while IRR is stored in I%YR.  


*  Solvers:  Cost/Price/Margin, Old/New/% Change, Nominal Rate vs. Effective 

Rate, Total/Part/% of the Total


*  Schedules:  ROI% (return on investment), Breakeven, and Inventory with Turnover analysis.   The schedules will make use of the down arrow key [ ↓ ], up arrow [ shift ] ( ↑ ), and the COMPUTE function [ shift ] (COMPUTE).  


*  Statistics:  One variable and two-variable.  Regressions included are:  


Linear:  y = m * x + b

Exponential:  y = b * e^(m * x)

Logarithmic:  y = b + m * ln x

Power:  y = b * x^m


There is also a Best fit mode, which decides the regression model based on the best correlation between the four modes.   


There are also two prediction sets  Going through the STAT menu, you can predict x and y values based on the chosen model.  Going through the FRCST (forecast) menu, the regression used is determined by the regression with the best correlation.


The Math menu contains three functions:  e^x, ln, and n!  (factorials for positive integers only).  


The 14B operates in chain mode, meaning no order of operations is followed.  The 14B operates similar to a four-function calculator in this regard.  


I think the 14B is set to be an intermediate finance calculator between the 10B and the 17B, which the 17B allows for user equations.  

The display will not only give just numbers but will also label the variables, which I always find useful.   



Golden Anniversary


The HP 14B 50th Anniversary Edition has a gold circle with a 50 logo on the top right side of the calculator.  Also on the engravement is the years 1939 - 1989.  On the leather holder, there is also the 50/1939 - 1989 logo engraved into the leather case.   


The HP 14B 50th Anniversary edition is the same of the "normal" HP 14B calculator in terms of features and excellent keyboard.


The HP 14B is part of Hewlett Packard's pioneer series, which the series includes the HP 20S, 21S, 22S, 27S, 42S, 17B, 17BII, 10B, 32S, 32SII, and 32S 50th Anniversary Edition.  It is my favorite series of Hewlett Packard calculators, both in terms of the features the calculators have and the high quality keyboards the calculators have.


50th edition calculators are available through online auction sites such as eBay for a reasonable price.  Perhaps I may add a 32S 50th Anniversary Edition to my collection.  

 


Sources:


"HP 14-B 50th Anniversary Limited Edition"   Museum of HP Calculators

https://www.hpmuseum.org/hp14b50.htm   Retrieved January 11, 2023


HP 14B Business Calculator Owner's Manual.  Hewlett Packard 

October 1988.  Download the English version here:  https://literature.hpcalc.org/items/574


Eddie


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


First Look: HP 16C Collector's Edition

 First Look: HP 16C Collector's Edition I just got the HP 16C Collector's Edition.   This is the famous HP 16C that specializes in c...