Posts

Creating Two Sample Mean Test with LAMBDA

Image
You received glass window samples from two different vendors. You wish to check if the thickness of the samples are the same. Based on the samples, you obtain the following data: Vendor Sample Sample 1 Sample 2 Mean (cm) 2.0 2.3 Standard Deviation (cm) 0.2 0.3 Number of Samples 15 20 At first glance sample 2 is 0.3cm thicker than sample 1. But are their thickness significantly different? To make a comparison you would need a perform a Two Sample Mean test . Two Sample Mean Test A two sample mean test compares two sample distribution means against each other. It differs from the one sample mean test that compares against a target value. We write the Null Hypothesis as the means of sample 1 and of sample 2 are equal. `H_0: mu_1 = mu_2` And the Alternative Hypothesis as the mean of sample 1 and of sample 2 are not equal. `H_1: mu_1 != mu_2` We could also test

Extending One Sample Mean Test for Arrays

Image
In the previous blog, I implemented a One Sample Mean hypothesis test in Excel LAMBDA. When given an array of sample data, we firstly calculate the sample mean, standard deviation and size, before passing these into the function. The function compares a sample mean against an expected population mean. In this blog, we will create a new function to take the sample data array directly, calculate the necessary statistics, and then reuse the One Sample Mean function to perform the hypothesis test. This extension ensures the same result regardless of the approach used. Parameter Changes In the earlier One Sample Mean dcrMean.One.TTest the input parameters were defined as: dcrMean.One.TTest =LAMBDA(expected_mean, sample_mean, sample_stdev, sample_size, [tail], [show_details], To implement One Sample Mean test for array,  dcrMean.One.TTest.Array  input parameter will take the entire data array: dcrMean.One.TTest.Array =LAMBDA(expected_mean, array, [tail], [show_details], Within this

Excel Range vs Array

Image
As I worked more with LAMBDA, I discovered that Excel functions that take range parameters do not work with arrays . If a function's parameter mentions "range", you can be sure this will not work with arrays. Some examples of these functions are COUNTIF , COUNTIFS , AVERAGEIF , AVERAGEIFS , SUMIF , and SUMIFS . The other that I am aware of is RANK.AVG . What is an Array? A Range represents a cell, a row, a column, a selection of selections, or blocks of cells. Range will always have an address, for example B2:B5 is a range of values stored in a column. An Array is a set of values constructed using a formula. For example  ={1;2;3;4} is column of values. =VSTACK(1,2,3,4) is also a column of values. The FORMULATEXT function would return #N/A in a range cell that contains only values. On the other hand it returns the formula used to construct the array values. An array can be displayed on a spreadsheet. When displayed on the spreadsheet, the values can be referred by the

Creating One Sample Mean Test with LAMBDA

Image
Suppose you visited a village. The village elders claims to possess a secret elixir that makes their children grower taller! You are aware of the national 12-year old  average height is 150cm. And you could measure the village's 12-year old children's height. Plotting the village's children's height gives you a distribution like in the graph above. At first glance the village's children does seem taller than the national average. Is the village's children really taller? Is the distribution significantly different? One Sample Mean Test A one sample mean test compares a sample distribution's mean against a target value. It is similar to the one proportion test but the sample data is continuous, giving a normal distribution curve instead of a yes/no binary result. We write the Null Hypothesis as the sample mean equal to the population mean. `H_0: mu = mu_0` And the Alternative Hypothesis as the sample mean not equal to the population mean. `H_1: mu != mu_0` We

It's a Red Panda! *Shocker* but I am used to calling myself DC Racoon

Image
I discovered that the above stuff toy represents a Red Panda ! *Shocker* I thought it was a racoon. However I am in good company. I read that scientists in the past also thought the red panda was a racoon. As it turned out, the red panda is no where near the racoon family. If anything it is closer to that of a cat! While DC Red Panda or DC Panda sounds cool, I am too used to calling myself DC Racoon. Next time, I'll check with my child first.

Creating Two Proportion Test with LAMBDA

Image
What is Two Proportion Test Two Proportion Test compares one proportion to determine if it is equal to, lesser than or greater than another proportion. Unlike One Proportion Test , the size of the second proportion can have an effect on the results. Suppose you gave flavour X ice-cream to two groups of people. In the first group 65 of 100 people liked flavour X, and in the second group 90 of 130 people liked. Did this two groups responded similarly? We write our hypothesis statement as the "Did the two groups responded similiarly to flavour X ice-cream?" The Null and Alternative Hypothesis is written as: `H_0: p_1 = p_2` `H_1: p_1 != p_2` where `p_1` is proportion from group 1 `p_2` is proportion from group 2 Test Statistics The equation of a two proportion test statistics is written as `z = (p_1 - p_2) / sqrt( hat p(1 - hat p)(1/n_1 + 1 / n_2) )` where the pooled variance `hat p = (o_1 + o_2)/(n_1 + n_2)` and `p_1 = o_1 / n_1` is the proportion from group 1 `p_2 = o_2 / n_2

Creating One Proportion Test with LAMBDA

Image
What is One Proportion Test The One Proportion Test compares a sample proportion against a target proportion. For example, you observe that you get 6 heads when you flip a coin 10 times (sample). You expect with a fair coin, the probability of getting heads is 0.5 or 50% of the time (target). The One Proportion Test allows you to assess if the flipped coin is a fair coin based on the observations. The test proves this by statistically comparing the observed proportion of heads to number of flipping 0.6, is equal to the expected proportion 0.5. We write the Null Hypothesis as the observed proportion is equal to the hypothesised proportion. `H_0: p = p_0` And the Alternative Hypothesis is that the observed proportion is not equal to the hypothesised proportion (two-tailed test). `H_1: p != p_0` We could also test if the observed proportion is greater than the hypothesised proportion (left tail test). `H_0: p >= p_0` Or if the observed proportion is less than the hypothesised proporti