Extending One Sample Mean Test for Arrays

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 function, the mean, standard deviation and size of the array will be pre-calculated before passing into the hypothesis test. Putting all these together we get:

dcrMean.One.TTest.Array
=LAMBDA(expected_mean, array, [tail], [show_details],
    LET(tail, IF(ISOMITTED(tail), 0, tail),
      show_details, IF(ISOMITTED(show_details), FALSE, show_details),
      sample_mean, AVERAGE(array),
      sample_stdev, STDEV.S(array),
      sample_size, COUNT(array),
      dcrMean.One.TTest(expected_mean, sample_mean, sample_stdev, sample_size, tail, show_details)
    )
)

In this function we showed one LAMBDA function can call another if it exists within the same Excel workbook. Reusable functions save time and also increase quality in your DC-DEN!

Comments