In this installment the Nelder-Mead method is used to train a simple neural network for the XOR problem. The network consisted of 2-input, 1-output, and 2 hidden layers, and is fully connected. In mainstream practical neural network, back propagation and other evolutionary algorithms are much more popular for training neural network for real world problem. Nelder-Mead is used here just out of curiosity to see how this general optimization routine performed under neural network settings on TI Nspire.
The sigmoid function is declared in an TI Nspire function.
For the XOR problem, the inputs are defined as two lists, and the expected output in another.
The activation functions for each neuron are declared.
To train the network, the sum of squared error function is used to feed into the Nelder-Mead algorithm for minimization. Random numbers are used for initial parameters.
Finally the resulting weights and bias are obtained from running the Nelder-Mead program.
The comparison graph of the performance of the Nelder-Mead trained XOR neural network against expected values.
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.
From the “HP 12C Platinum Solutions Handbook”, an example is given on calculation of refinancing an existing mortgage (on page 7). Since the HP 12C is a special breed specializing in financial calculations, much of the steps are optimized and is different from using financial functions available on other higher end calculators like the TI Nspire. In the following re-work of the same example, the Finance Solver is called from within the Calculator Page and the Vars are recalled for calculations.
Monthly payment on existing mortgage received by lender calculation.
Monthly payment on new payment calculation.
Net monthly payment to lender, and Present value of net monthly payment calculation.
The Bonferroni procedure can be used in multiple comparison to determine which means differ. Using a sample set of data below with three groups of equal size data, the ANOVA 2-way function is calculated and the results stored in stat1. For convenience, the standard ANOVA is also calculated and the results stored in stat6.
The original confidence level is set to 0.05. To obtain the corrected confidence level value, 0.05 is divided by the number of group of data, and then by 2 for 2-tail test. The new critical t-value is then determined. The means for each group is available in the stat6 variable set (by ANOVA), while the pooled standard deviation s can be obtained from stat1 variable set (by ANOVA 2-way).
And then for each of the combination of group, calculate its new t-value, i.e. GA-GC, GB-GC, and GA-GB respectively.
As shown above, the combination of GA-GB is less than the critical value of 2.7178, meaning that fail to reject H0 and therefore can conclude that μA=μB.
The Mahalanobis distance is an important method in statistical analysis. It is a different thinking from the common Euclidean distance and considered the dimensionality of standard deviation. In TI Nspire, there is no built-in function for Mahalanobis distance. However, it can be easily calculated using the matrix operations available.
Using independent variables x1, x2, and dependent variable y. Firstly, the covariance matrix is obtained by either the first inverse matrix equation above, or the next one where d is defined as row-wise as x1, x2, and a last row of 1’s.
Once the covariance matrix is determined, the Mahalanobis distance for x1, x2 can be determined by the above equation, which is a summation of distances times the number of observation minus one. The use of a sum function on matrix is just for convenience of input and display as the summation function can be very long.