MCPサーバー

simulate-monte-carlo

io.github.encodi/simulate-monte-carlo
データ・分析 科学・工学 利用不可 MCP 2025-11-25

このMCPでできること

Runs Monte Carlo simulations for compound events and conditional probabilities using declared random distributions.

simulate_monte_carlo
Simulate a compound event or conditional probability (Monte Carlo)
Actually draws random samples from real distributions and counts outcomes, instead of a model guess about a probability. Declare named random variables (uniform, normal, bernoulli, binomial, poisson, exponential, discrete), an "event" boolean expression over those variable names (e.g. "a > 0.5 && b == 1"), and an optional "condition" expression to estimate a conditional probability P(event | condition) by rejection sampling. Event/condition expressions are parsed and evaluated by a small built-in interpreter (arithmetic, comparisons, &&/||/!, min/max/abs) — no arbitrary code execution. Returns the estimated probability, a 95% confidence interval, and the seed used (pass the same seed back to reproduce the exact result). Costs $0.03 USDC (Base) per call.
入力スキーマ
{'type': 'object', '$schema': 'https://json-schema.org/draft/2020-12/schema', 'required': ['variables', 'event'], 'properties': {'seed': {'type': 'integer', 'maximum': 9007199254740991, 'minimum': -9007199254740991, 'description': 'Optional PRNG seed for a reproducible run. If omitted, a random seed is generated and returned in the output.'}, 'event': {'type': 'string', 'maxLength': 500, 'description': 'Boolean expression over the variable names, evaluated each trial (e.g. "a + b > 10", "x == 1 && y < 0.2").'}, 'trials': {'type': 'integer', 'maximum': 100000, 'minimum': 100, 'description': 'Number of trials to run. Default 10000, between 100 and 100000.'}, 'condition': {'type': 'string', 'maxLength': 500, 'description': 'Optional boolean expression; if given, the result is P(event | condition), estimated only over trials where this is true.'}, 'variables': {'type': 'array', 'items': {'type': 'object', 'required': ['name', 'distribution'], 'properties': {'name': {'type': 'string', 'pattern': '^[a-zA-Z_][a-zA-Z0-9_]*$', 'description': 'Variable name, referenced by "event"/"condition" (e.g. "a", "wait_time").'}, 'distribution': {'oneOf': [{'type': 'object', 'required': ['type', 'min', 'max'], 'properties': {'max': {'type': 'number'}, 'min': {'type': 'number'}, 'type': {'type': 'string', 'const': 'uniform'}}, 'description': 'Continuous, equally likely between min and max.'}, {'type': 'object', 'required': ['type', 'mean', 'stdDev'], 'properties': {'mean': {'type': 'number'}, 'type': {'type': 'string', 'const': 'normal'}, 'stdDev': {'type': 'number', 'minimum': 0}}, 'description': 'Gaussian/bell curve, via Box-Muller sampling.'}, {'type': 'object', 'required': ['type', 'p'], 'properties': {'p': {'type': 'number', 'maximum': 1, 'minimum': 0}, 'type': {'type': 'string', 'const': 'bernoulli'}}, 'description': 'Single 0/1 trial with success probability p.'}, {'type': 'object', 'required': ['type', 'n', 'p'], 'properties': {'n': {'type': 'integer', 'maximum': 1000, 'exclusiveMinimum': 0}, 'p': {'type': 'number', 'maximum': 1, 'minimum': 0}, 'type': {'type': 'string', 'const': 'binomial'}}, 'description': 'Count of successes in n independent Bernoulli(p) trials. n capped at 1000.'}, {'type': 'object', 'required': ['type', 'lambda'], 'properties': {'type': {'type': 'string', 'const': 'poisson'}, 'lambda': {'type': 'number', 'maximum': 1000, 'exclusiveMinimum': 0}}, 'description': "Event count with mean rate lambda, via Knuth's algorithm. lambda capped at 1000."}, {'type': 'object', 'required': ['type', 'rate'], 'properties': {'rate': {'type': 'number', 'exclusiveMinimum': 0}, 'type': {'type': 'string', 'const': 'exponential'}}, 'description': 'Time between events at the given rate.'}, {'type': 'object', 'required': ['type', 'values', 'weights'], 'properties': {'type': {'type': 'string', 'const': 'discrete'}, 'values': {'type': 'array', 'items': {'type': 'number'}, 'maxItems': 20, 'minItems': 1}, 'weights': {'type': 'array', 'items': {'type': 'number', 'minimum': 0}, 'maxItems': 20, 'minItems': 1}}, 'description': 'Weighted pick from a custom list of outcomes (e.g. a die). Up to 20 outcomes.'}]}}}, 'maxItems': 10, 'minItems': 1, 'description': 'Random variables to sample each trial. Max 10.'}}}
出力スキーマ
{'type': 'object', '$schema': 'https://json-schema.org/draft/2020-12/schema', 'required': ['valid', 'error', 'trials_run', 'seed_used', 'probability', 'event_successes', 'condition_successes', 'standard_error', 'confidence_interval_95'], 'properties': {'error': {'anyOf': [{'type': 'string'}, {'type': 'null'}], 'description': 'Error or warning message. null if none.'}, 'valid': {'type': 'boolean', 'description': 'false if the input (variables, expressions, limits) was invalid.'}, 'seed_used': {'type': 'number', 'description': 'The PRNG seed used â\x80\x94 pass it back as `seed` to reproduce this exact result.'}, 'trials_run': {'type': 'number', 'description': 'Number of trials actually simulated (0 if valid is false).'}, 'probability': {'anyOf': [{'type': 'number'}, {'type': 'null'}], 'description': 'Estimated P(event) or P(event | condition). null if invalid, or if condition matched zero trials.'}, 'standard_error': {'anyOf': [{'type': 'number'}, {'type': 'null'}], 'description': 'Estimated standard error of the probability estimate.'}, 'event_successes': {'type': 'number', 'description': 'Number of trials (or condition-matching trials) where event was true.'}, 'condition_successes': {'anyOf': [{'type': 'number'}, {'type': 'null'}], 'description': 'Number of trials where condition was true. null if no condition was given.'}, 'confidence_interval_95': {'anyOf': [{'type': 'array', 'prefixItems': [{'type': 'number'}, {'type': 'number'}]}, {'type': 'null'}], 'description': 'Approximate 95% confidence interval [low, high] via the normal approximation.'}}, 'additionalProperties': False}
追加
simulate_monte_carlo
2026年9月17日12:41