1Using R as a Research ToolSome Pseudocode for **Stat**istical Hypothesis-Testing1. Conventional t-**test**:Calculate means and variances for each of two samples.Calculate ˆt , the **test**-statistic value for the observed data.Calculate the degrees of freedom corresponding to the data.Find the tail probability (significance level) of ˆt from the corresponding null t-distribution,based on whether the **test** is left-tailed, right-tailed, or two-tailed.Return the **test**-statistic value and probability level.2. Simulation of the null distribution of the t-statistic:Create a large population of values for a single variable.For each of nIters iterations:Draw two random samples of sizes n 1 and n 2 from the population.Calculate the sample means and variances for the two samples.Calculate ˆt , the **test**-statistic value for the observed data.Stash ˆt into a vector containing the accumulating null distribution.End for.Draw the null distribution as a histogram.3. Randomized t-**test**:Calculate means and variances for each of two samples.Calculate ˆt , the **test**-statistic value for the observed data.For each of nIters iterations:Combine the data from the two samples.Randomly permute the data values.Split the permuted data into two samples having the same sizes as the original samples.Calculate t rand, the **test**-statistic value for the randomized data.Stash t randinto a vector containing the accumulating null distribution.End for.Find the tail probability (significance level) of ˆt from the randomized null distribution,based on whether the **test** is left-tailed, right-tailed, or two-tailed.Return the **test**-statistic value and probability level.

24. Randomized **test** for difference in diversity:Calculate the diversity values H 1 and H 2 for the two samples based on the frequencies ofclasses of items.Calculate H H1 H2, the **test**-statistic value for the observed data.For each of nIters iterations:Combine the data from the two samples.Randomly permute the data values.Split the permuted data into two samples having the same sizes as the original samples.Calculate the diversity values H 1,rand and H 2,rand for the two samples based on thefrequencies of classes of items.Calculate Hrand H1, rand H2,rand, the **test**-statistic value for the randomized data.Stash Hrandinto a vector containing the accumulating null distribution.End for.Find the tail probability (significance level) of H from the randomized null distribution,based on whether the **test** is left-tailed, right-tailed, or two-tailed.Return the **test**-statistic value and probability level.