Skip to main content
Glama

weighted_stats

Compute weighted statistics (mean, median, percentiles, min, max, std) for a numeric survey variable, with optional filtering and grouping by another variable.

Instructions

Compute weighted descriptive statistics for a variable.

Args: variable: The numeric variable to analyze (e.g., 'ingc_pc', 'educ'). filter: Optional filter expression (e.g., "sexo == 1"). by: Optional grouping variable (e.g., "region", "sexo", "cohorte"). dataset: Which dataset to use (default: entrevistado).

Returns weighted mean, median, std, percentiles (25th, 75th), min, max, and sample sizes. If 'by' is specified, returns stats per group.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
variableYes
filterNo
byNo
datasetNoentrevistado

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It discloses the input parameters and return statistics but does not mention how missing data is handled, whether the variable must exist, any assumptions about weighting (e.g., survey weights), or performance implications. Behavioral details are minimal.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description uses a docstring format with 'Args:' and 'Returns' sections, which is structured but somewhat verbose. It frontloads the purpose, then lists parameters. Some redundancy exists as parameter details are already in the input schema. Could be more concise by removing the 'Args:' label.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers all parameters and return values, and an output schema exists for return details. However, it lacks discussion of edge cases (e.g., missing data, invalid variable), error handling, or details on how weights are applied. For a statistical tool with 4 parameters, it is adequate but not comprehensive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds examples for 'variable' and 'by' and explains the default for 'dataset'. However, it does not specify valid values for 'filter' or 'dataset', nor the syntax for filter expressions. It adds moderate meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states that the tool computes weighted descriptive statistics for a variable, listing specific statistics and grouping capability. It distinguishes itself from sibling tools like 'tabulate' or 'compare_groups' by focusing on weighted statistics with numpy-style functions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains when to use this tool (to compute weighted stats with optional filtering and grouping). However, it does not specify when NOT to use it or mention alternative tools (e.g., 'tabulate' for frequencies, 'compare_groups' for comparisons). No prerequisites or exclusions are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Lalitronico/emovi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server