# Graphical visualization of data distribution in TI-84 and R

For visualizing data distribution, the TI-84 Stat plot can provide some insights. Using the same data set as in the previous installment on Shapiro-Wilk test, TI-84 Stat plot is a quick and convenient tool.  In R, the command qqnorm() will show the following plot for the same data. # P value of Shapiro-Wilk test on TI-84

To calculate the p-value from this W statistic obtained, the following steps can also be done on the TI-84 using some standard statistics function. Note that the approximation below are for the case 4 ≤ n ≤ 11.

The mean and standard deviation are derived using the below equations. The W statistic is assigned from the correlation calculation results, and another variable V is calculated for the transformed W. Finally, the standardized Z statistic and p-value is calculated using the mean, standard deviation, and the transformed W value.  # Performing Shapiro-Wilk test on TI-84

On TI-84, although the Shapiro-Wilk test is not available as built-in function, it is possible to calculate the W statistics by using the calculator’s rich set of list and statistics function. It is not trivial, but doable.

First set up a list of sample values. Using the example from the original Shapiro-Wilk paper, the samples are input into a list called W, while the N variable denotes the dimension and U stores inverse of its square root. The data sample in W must be sorted in ascending order.  Next is to generate the M list based on W. This list is to calculate the inverse normal distribution based on the index value and the dimension of W list. Doing this in TI-84 is easy with the help of the seq() function. The complete expression is:
`seq(invNorm( (I-0.375) / (N+0.25), 0, 1), I, 1, N, 1)`  Now that the List M is ready, it is time to derive the sum of square of it and we store it into variable m (not the list M). Since the approximation algorithm is used instead of look up table as proposed in the original paper, the next step is to prepare List A. This list is arranged in such a way that the first two and last two elements have different calculation than all the others. The last two values (N-1, N) of List A are prepared in the Y5 and Y6 equations. These are approximating equations. The first two elements are the negation of these two in a particular order.  One more variable, ε, has to be calculated at this point before we generate List A.
`(m - 2*M(N)² - 2*M(N-1)²) / (1 - 2*Y6² - 2*Y5²)` Next is to generate the List A. As explained, four elements namely the first, second, N-1, and N elements of this list is calculated unlike all other elements. The screen below is for all except that four special elements. The remaining steps for the four elements of this List A are then carried out as below. Finally, all three lists are ready for calculation. To calculate the W statistics, use the Linear Regression function in the TI-84 as below for W and A. The correlation coefficient r² is the W statistics as shown in R. See the next installment for the Z statistic and P value calculations from this W statistic, also on the TI-84.  # Visualizing room temperature pattern with IoT

On my desk there is an IoT device that measures temperature and log data to the Internet. It is a hobby project build with Texas Instruments MSP430 series MCU, with an IR temperature sensor TMP006 (Infrared Thermopile Contactless Temperature Sensor) also from TI. The temperature data are published via an OpenWRT TP-Link router to Exosite which is running a partnership program with TI on IoT services. Last night I noticed something I never noticed before – a clear pattern of a less fluctuating period (around 19:00 to 21:00). Possible cause: I turned off the fan to go dine out. When I’m back the fan is back on, added to the environmental factor that my body temperature and the turbulence from the fan lead to the fluctuation – just wild guess, it’s weekend 🙂

# Shapiro-Wilk test for normality

The Shapiro-Wilk test is suitable for testing normality. The result as presented in p-value is easy to interpret. In the original form there is limit of 8 to 50 samples. A revised approximation method exists that can extend the number to 5000. The calculation steps are quite complex for hand held calculator like in the TI-84. In R there is a built-in function. Using the example in the original paper of Shapiro-Wilk test to calculate this statistics in R is simple: # Handy custom functions in TI Nspire for temperature conversion

The TI Nspire provided comprehensive unit conversion and one of the most used is working between Celsius and Fahrenheit. However, accessing these in the Calculator page is not quite straightforward. To save some keystrokes, some handy functions can easily be written in the MyLib folder to call these built-in functions.

While it looks like a piece of cake, there seems to be some quirks on the program editor that inadvertently changed the program code. And no matter how the line of function below being typed, it turned into something that will cause syntax error after Check Syntax and Store. This is the original program as typed in: ..being changed to weird code after “Check Syntax and Store”: A simple solution is to just add an one in between and the compiler will not monkey with the code anymore. # Adjusting graph settings for discrete variable for TI Nspire and HP Prime

On the TI Nspire, plotting of graph with discrete values sometimes do not easily give desired results. Consider plotting

`ln(nCr(50,x))`

Using 2D graph, Nspire will actually plot the graph but is seemingly having problems connecting the points. Not only after the integer function is added into the equation, the graph can be visualized properly. Experimenting with the Trace function below, the red trace disappears on real X values between two discrete integers, confirming the plot is there but the engine is having problem connecting. In contrast, the HP Prime provided an Integer view of graph for this case.    