HP Prime and TI-84 Plus CE: Percent Change on Paired Data
Introduction
Given a two column matrix, the programs here calculate the percent difference on each row. The first column is the old value while the second column is the new value.
HP Prime Program %CHGPAIRED
EXPORT %CHGPAIRED(m0)
BEGIN
// Δ% on a 2 column matrix
// 2019-03-31 EWS
LOCAL k,s:=SIZE(m0);
LOCAL n:=s(1);
LOCAL m1:=MAKEMAT(0,n,1);
FOR k FROM 1 TO n DO
m1(k,1):=%CHANGE(m0(k,1),m0(k,2));
END;
RETURN m1;
END;
TI-84 Plus Program CHGPAIR
"2019-03-31 EWS"
Disp "PCHG PAIRED DATA"
Input [J]
dim([J])→L₆
L₆(1)→N
{N,1}→dim([I])
For(K,1,N)
([J](K,2)-[J](K,1))/[J](K,1)*100→[I](K,1)
End
Pause [I]
Example
M =
[[ 1, 6 ], [ 4, 2 ], [ 3, 7 ], [ 6, 5 ], [ 4, 11 ]]
Result:
[[ 500 ], [ -50 ], [ 133.3333333 ], [ -16.6666667 ]]
[picture]
Source: "Probability and Statistics: Step by Step Solutions for Your HP-28S or HP-28S Calculator" Hewlett Packard. November 1987.
Eddie
All original content copyright, © 2011-2019. 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.
Introduction
Given a two column matrix, the programs here calculate the percent difference on each row. The first column is the old value while the second column is the new value.
HP Prime Program %CHGPAIRED
EXPORT %CHGPAIRED(m0)
BEGIN
// Δ% on a 2 column matrix
// 2019-03-31 EWS
LOCAL k,s:=SIZE(m0);
LOCAL n:=s(1);
LOCAL m1:=MAKEMAT(0,n,1);
FOR k FROM 1 TO n DO
m1(k,1):=%CHANGE(m0(k,1),m0(k,2));
END;
RETURN m1;
END;
TI-84 Plus Program CHGPAIR
"2019-03-31 EWS"
Disp "PCHG PAIRED DATA"
Input [J]
dim([J])→L₆
L₆(1)→N
{N,1}→dim([I])
For(K,1,N)
([J](K,2)-[J](K,1))/[J](K,1)*100→[I](K,1)
End
Pause [I]
Example
M =
[[ 1, 6 ], [ 4, 2 ], [ 3, 7 ], [ 6, 5 ], [ 4, 11 ]]
Result:
[[ 500 ], [ -50 ], [ 133.3333333 ], [ -16.6666667 ]]
[picture]
Source: "Probability and Statistics: Step by Step Solutions for Your HP-28S or HP-28S Calculator" Hewlett Packard. November 1987.
Eddie
All original content copyright, © 2011-2019. 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.