docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
Build a custom math module that extends mathjs with additional statistical functions for analyzing datasets.
Your task is to create a module that adds custom statistical functions to a mathjs instance. The module should provide functions for calculating the geometric mean and harmonic mean of datasets.
Implement a geometricMean function that calculates the geometric mean of an array of numbers. The geometric mean is calculated as: (x₁ × x₂ × ... × xₙ)^(1/n)
Implement a harmonicMean function that calculates the harmonic mean of an array of numbers. The harmonic mean is calculated as: n / (1/x₁ + 1/x₂ + ... + 1/xₙ)
evaluate("geometricMean([4, 9])") @test/**
* Creates a mathjs instance with custom statistical functions.
*
* @returns {object} A mathjs instance with geometricMean and harmonicMean functions
*/
function createCustomMath() {
// IMPLEMENTATION HERE
}
module.exports = { createCustomMath };Provides mathematical functionality and extensibility support.