Posts

Showing posts with the label Name Manager

Recursion: LAMBDA calling LAMBDA

Image
Excel Lambda functions can be used to create custom, reusable functions by giving them a friendly name. This means a custom Lambda function could call itself. A recursive function is a function that calls itself and self-moves towards an exit condition. Without the exit condition, the function loops continuously unless externally terminated. Why use recursion? Some problems can be expressed in an elegant recursive structure. For example the n-th factorial is defined as: `n! = n (n-1) (n-2) ... 1` with the termination condition: `0! = 1` Recursion example using Lambda Before we start, Excel provides the FACT function to calculate the factorial of a number. You can use this to compare the results of your own. This is an example of a recursive function MyFactorial =LAMBDA(n, IF(n = 0, 1, n * MyFactorial(n-1) ) ) The IF function is used to determine the termination condition. If the termination condition has not been reached, decrement the variable by 1 and call the functi

Creating Standard Error function with Excel LAMBDA

Image
LAMBDA  is available in Excel for Microsoft 365 and Excel for the Web. LAMBDA allows users to implement custom Excel formulae without resorting to VBA macros. LAMBDA essentially keeps Excel within Excel. This blog build various reusable statistical features and inference functions using LAMBDA. For a start, we will implement the Standard Error for a sample mean. Firstly the Standard Error for a sample mean is defined as: The syntax for LAMBDA is =LAMBDA([parameter1, parameter2, …,] calculation)  So the LAMBDA function implementation would be =LAMBDA(array, STDEV.S(array)/SQRT(COUNT(array)) ) The array is the input parameter or variable, while the STDEV.S(array)/SQRT(COUNT(array))  part is the standard error calculation. To create this LAMBDA as a reusable function: Open Excel > Formulas > Name Manager In the Name Manager dialog, click New Enter: Name: dcrStErr Comments: Returns the standard error of a sample mean. Refers to: =LAMBDA(array, STDEV.S(array)/SQRT(COUNT(array))) Cli