Skip to main content
Glama

generate_distribution

Generate random numbers based on specified probability distributions like uniform, normal, exponential, and binomial. Useful for simulations, risk analysis, statistical sampling, and load testing.

Instructions

Probability Distribution Random Generator

Generate random numbers according to specified probability distribution type and parameters.
Supports various common probability distributions.

Args:
    distribution_type (int): Distribution type:
        1 = Uniform distribution (parameters: [min_value, max_value])
        2 = Normal distribution (parameters: [mean, standard_deviation])
        3 = Exponential distribution (parameters: [scale_parameter])
        4 = Binomial distribution (parameters: [trials, success_probability])
    distribution_parameters (List[float]): Distribution parameter list
    salt (str, optional): Random number salt value for increased randomness. Defaults to "".

Returns:
    str: JSON string containing random value and distribution information, formatted as:
    {
        "requestId": "Generated request ID",
        "randomValue": Generated random value,
        "distributionMetadata": {
            "distributionType": Distribution type,
            ...Distribution parameters
        }
    }

Application Scenarios:
1. Financial market simulation (return distribution, risk analysis)
2. Natural phenomena simulation (particle distribution, noise generation)
3. Load testing (user behavior distribution)
4. Statistical sampling (experimental data generation)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
distribution_parametersYes
distribution_typeYes
saltNo

Implementation Reference

  • main.py:142-175 (handler)
    MCP tool registration and handler wrapper for generate_distribution. Delegates to the distribution_generator utility function.
    @mcp.tool()
    async def generate_distribution(distribution_type: int, distribution_parameters: List[float], salt: str = "") -> str:
        """Probability Distribution Random Generator
    
        Generate random numbers according to specified probability distribution type and parameters.
        Supports various common probability distributions.
    
        Args:
            distribution_type (int): Distribution type:
                1 = Uniform distribution (parameters: [min_value, max_value])
                2 = Normal distribution (parameters: [mean, standard_deviation])
                3 = Exponential distribution (parameters: [scale_parameter])
                4 = Binomial distribution (parameters: [trials, success_probability])
            distribution_parameters (List[float]): Distribution parameter list
            salt (str, optional): Random number salt value for increased randomness. Defaults to "".
    
        Returns:
            str: JSON string containing random value and distribution information, formatted as:
            {
                "requestId": "Generated request ID",
                "randomValue": Generated random value,
                "distributionMetadata": {
                    "distributionType": Distribution type,
                    ...Distribution parameters
                }
            }
    
        Application Scenarios:
        1. Financial market simulation (return distribution, risk analysis)
        2. Natural phenomena simulation (particle distribution, noise generation)
        3. Load testing (user behavior distribution)
        4. Statistical sampling (experimental data generation)
        """
        return await distribution_generator(distribution_type, distribution_parameters, salt)
  • Core implementation of the distribution generator using NumPy for uniform, normal, exponential, and binomial distributions. Derives seed from blockchain random source.
    async def distribution_generator(distribution_type: int, distribution_parameters: List[float], salt: str="") -> Dict:
        """
        Distribution random generator
        
        Generate random numbers following specified probability distribution
        
        Args:
            distribution_type: Type of distribution:
                1 = Uniform distribution
                2 = Normal distribution
                3 = Exponential distribution
                4 = Binomial distribution
            distribution_parameters: Parameters for the distribution
            salt: Optional salt value for additional randomness
            
        Returns:
            Dict containing random value and distribution metadata
        """
        random_num = await get_random_str()
        if not random_num:
            return {"error": "Failed to get random number"}
        request_id = generate_request_id(random_num)
        seed = _derive_seed(request_id, salt)
        np.random.seed(seed)
        
        metadata = {"distributionType": distribution_type}
        
        if distribution_type == 1:  # Uniform distribution
            min_val, max_val = distribution_parameters
            random_value = float(np.random.uniform(min_val, max_val))
            metadata.update({"min": min_val, "max": max_val})
            
        elif distribution_type == 2:  # Normal distribution
            mean, std_dev = distribution_parameters
            random_value = float(np.random.normal(mean, std_dev))
            metadata.update({"mean": mean, "stdDev": std_dev})
            
        elif distribution_type == 3:  # Exponential distribution
            scale = distribution_parameters[0]
            random_value = float(np.random.exponential(scale))
            metadata.update({"scale": scale})
            
        elif distribution_type == 4:  # Binomial distribution
            n, p = distribution_parameters
            random_value = int(np.random.binomial(n, p))
            metadata.update({"trials": n, "probability": p})
            
        else:
            raise ValueError("Unsupported distribution type")
        
        result = {
            "requestId": request_id,
            "randomValue": random_value,
            "distributionMetadata": metadata
        }
        
        return result
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes the tool's function and return format but lacks details on error handling, rate limits, or side effects. It mentions the 'salt' parameter for 'increased randomness' but does not explain how this affects behavior or if there are any constraints. The description adds basic context but misses deeper behavioral traits.

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

Conciseness4/5

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

The description is well-structured with clear sections (purpose, args, returns, application scenarios) and front-loaded key information. However, the 'Application Scenarios' section is somewhat lengthy and could be more concise. Most sentences earn their place, but there is minor verbosity in the scenarios list.

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

Completeness4/5

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

Given the complexity (3 parameters, no annotations, no output schema), the description is largely complete. It explains the tool's purpose, parameters, and return format in detail. However, it lacks information on error cases or limitations (e.g., parameter validation, distribution constraints). For a tool with no structured output schema, the return format description is helpful but not exhaustive.

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

Parameters5/5

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

The schema description coverage is 0%, so the description must compensate. It provides detailed semantics for all parameters: 'distribution_type' with enumerated values and corresponding 'distribution_parameters' for each type, and 'salt' as optional for randomness. This adds significant meaning beyond the bare schema, fully documenting parameter usage and relationships.

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 the tool's purpose: 'Generate random numbers according to specified probability distribution type and parameters.' It specifies the verb ('generate') and resource ('random numbers') with the constraint of following probability distributions. It distinguishes from siblings like 'generate_basic_random' by emphasizing distribution-based generation rather than basic random number generation.

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

Usage Guidelines4/5

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

The 'Application Scenarios' section provides clear context for when to use this tool (e.g., financial simulation, natural phenomena simulation). However, it does not explicitly state when NOT to use it or name specific alternatives among the sibling tools (e.g., when to use 'generate_basic_random' instead). The guidance is contextual but lacks explicit exclusions or comparisons.

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

Related 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/suxiongye/random-web3-mcp'

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