Two variable regressions for Palm's RPN calculator

regressions.rpn implements linear, logarithmic, exponential and power two variable regressions for Palm's RPN calculator.

[ Intro | Usage | Sample | Mathematics | Software | Installation | Known problems ]


The following regression models are supported:
linear model
expected_y = a x + b
logarithmic model
expected_y = a ln x + b
exponential model
expected_y = b exp(a x)
power model
expected_y = b x**a
formulae mathematicae

regressions.rpn sums up the expressions x, x**2, y, y**2, x y, 1, ln x, (ln x)**2, y ln x, ln y, (ln y)**2, x lny, lnx lny. If any of the logarithmic models can't be supported due to negative values, then it will be disabled (correlation returns zero in this case). The user can also manually disable the logarithmic models.


[+] Sum up the expressions needed for the regression calculations. Returns the new n.
[-] Subtract expressions. This lets you correct entries made with [+]. Returns the new n.
clr Clear sums.
sum Calculate sums. Returns sum(x), sum(y)
mean Calculate mean values. Returns mean(x), mean(y)
wm Calculate the weighted mean. Returns wmean(x) where the yi are the weights.
sdev Calculate standard deviations. Returns sdev(x), sdev(y). Requires at least two sets of values.
Model Regression model chose dialog: best lin log exp pwr. best calculates all possible regression models and choses the one with the highest correlation-square. Returns the index of the chosen model.
x Calculate xf (forecast) from y.
y Calculate yf (forecast) from x.
a Slope parameter. Zero if the chosen model is illegal (because of negative values).
b Offset parameter.
r Correlation. Between -1 and 1. Values far from zero are better.


To calculate statistics and regressions on the following data sets, enter:

xi yi
11 Enter 2 [+]
13 Enter 3 [+]
17 Enter 5 [+]
19 Enter 7 [+]

Statistics results:

sumsum 17.0000 60.0000
meanmean 4.2500 15.0000
weighted meanwm 4.6500
standard deviationsdev 2.2174 3.6515

Regressions results:

model abr yf(11)xf(23)
lin1.62718.08470.9881 25.98319.1667
log6.58336.19960.9964 21.985612.8325
exp0.10999.19030.9781 30.77758.3489
pwr (best)0.44948.03950.9972 23.617810.3699

Math used

The regression parameters a and b are optimized for least squares. The two partial differentials produce a system of equations from which a and b can be calculated.

The correlation can be calculated from variances and covariance.

See any good math textbook for more information.

formulae mathematicae


Note: The program is free software; you can redistribute it and/or modify it. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

source: regressions.rpn
source stripped of comments and blanks, to fit into Palm's clipboard: regressions-s.rpn


  1. Download regressions-s.rpn (after reading the disclaimer).
  2. Create a new MemoPad entry from the regressions-s.rpn data. Note: the annotated source regressions.rpn won't fit into Palm's clipboard.
  3. Hotsync.
  4. Copy the transfered memo into Palm's clipboard.
  5. Switch to RPN.
  6. Import the script by "Add Set".

Known problems

Please send your bug reports, if you have any.

links: Palm Computing (palmsource, emulator) [formerly at 3Com (Palm)] [formerly at USR (Palm)] , RPN (software, documentation, archive, coweb) [formerly at Cornell]

Back to the Palm RPN page

Eric Laroche,, / Sat May 22 1999
Original URL: <URL:>