Array rational mean
array-rational-mean · version 1.0.0 · Numbers & math · free, no key needed
Return the reduced arithmetic mean of an array of canonical rationals.
Use when you need to: array rational mean · average of rationals · mean of an array of fractions.
Supported
- array rational mean
- average of rationals
- mean of an array of fractions
Not supported
- floating-point mean
- weighted mean
- median of rationals
- standard deviation
- decimal string mean
- IEEE-754 arithmetic
Behavior
- Input values is a non-empty array of rational objects with canonical integer-string numerator and denominator.
- Each denominator must be a positive canonical integer; zero and negative denominators are rejected.
- The mean is the reduced sum of the values divided by the array length n.
- A single-element array returns that element reduced.
- The sign lives only on the numerator; zero is numerator 0 over denominator 1.
- At most 10000 values. After reduction, numerator and denominator may each have at most 1000 digits excluding sign.
Input
values(array of object, required): min items 1; max items 10000
Output
numerator(string, required)denominator(string, required)
Limits
- max values: 10000
- max digits: 1000
- min values: 1
Example
Request input:
{
"values": [
{
"numerator": "1",
"denominator": "2"
},
{
"numerator": "1",
"denominator": "3"
},
{
"numerator": "1",
"denominator": "6"
}
]
}
Response:
{
"result": {
"numerator": "1",
"denominator": "3"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "array-rational-mean",
"version": "1.0.0",
"input": {
"values": [
{
"numerator": "1",
"denominator": "2"
},
{
"numerator": "1",
"denominator": "3"
},
{
"numerator": "1",
"denominator": "6"
}
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/array-rational-mean/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"values":[{"numerator":"1","denominator":"2"},{"numerator":"1","denominator":"3"},{"numerator":"1","denominator":"6"}]}'
The machine-readable contract is at /v1/tools/array-rational-mean/versions/1.0.0.
CLI
node cli.mjs run array-rational-mean 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Array rational min max: Return the reduced numeric minimum and maximum of an array of canonical rationals.
- Array rational sum: Sum an array of canonical rationals and return the reduced total.
- Rational multiply: Multiply two rational numbers given as numerator/denominator integer strings and return the reduced product.
- Rational subtract: Subtract one rational number from another, given as numerator/denominator integer strings, and return the reduced difference.
- Array integer GCD: Compute the non-negative greatest common divisor of an array of canonical integer strings.
- Array integer LCM: Compute the non-negative least common multiple of an array of canonical integer strings.