{
  "openapi": "3.1.1",
  "info": {
    "title": "Reaction Time Statistics API",
    "version": "1.0.0",
    "summary": "Mean, median, SD and outlier-trimmed reaction times from a pasted list of milliseconds.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://mindquarryreactionstats.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Mean, median, SD and outlier-trimmed reaction times from a pasted list of milliseconds.",
        "description": "Paste reaction times (from Mindquarry, a lab task, a game or a stopwatch) and get the raw mean, median, standard deviation and percentiles, plus the three common ways to deal with outliers side by side: fixed cut-offs for anticipations and lapses, mean ± k standard deviations, and median ± k scaled median absolute deviations, and a trimmed mean. Every value is flagged with the rule that removed it.\n\nMethodology:\n- Raw statistics use every value: mean, median and percentiles (linear interpolation between order statistics, “type 7”), sample standard deviation (n − 1) and coefficient of variation (SD / mean).\n- Absolute cut-offs first remove anticipations (faster than the lower limit) and lapses (slower than the upper limit). The SD rule, the MAD rule and the trimmed mean all start from the values inside these limits.\n- SD rule: keep values within mean ± k × SD. MAD rule: keep values within median ± k × 1.4826 × MAD (median absolute deviation, scaled to match the SD for normal data); it is not pulled by the outliers it is meant to find (Leys et al. 2013).\n- Trimmed mean: sort, drop floor(n × share) values from each end, average the rest. Reaction-time distributions are right-skewed, so the median and trimmed means are usually more representative than the plain mean (Ratcliff 1993).\n\nDescriptive statistics of your own numbers only; no comparison with population norms and no medical or diagnostic meaning.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "mindquarry_reaction_stats",
        "x-owner-app": "mindquarry",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MindquarryReactionStatsInput"
              },
              "examples": {
                "example1": {
                  "summary": "20 simple reaction times with an anticipation and two lapses",
                  "value": {
                    "times": "412 388 455 401 367 1290 395 420 140 433\n398 377 409 441 386 392 415 2405 404 399"
                  }
                },
                "example2": {
                  "summary": "Values in seconds with a decimal comma",
                  "value": {
                    "times": "0,412\n0,388\n0,455\n0,401\n0,367\n0,980\n0,395",
                    "unit": "s",
                    "decimalComma": true
                  }
                },
                "example3": {
                  "summary": "Stricter rules (2 SD, 2.5 MAD, 20 % trimmed)",
                  "value": {
                    "times": "412 388 455 401 367 1290 395 420 140 433\n398 377 409 441 386 392 415 2405 404 399",
                    "sdK": 2,
                    "madK": 2.5,
                    "trimPercent": 20
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MindquarryReactionStatsResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "MindquarryReactionStatsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "times": {
            "title": "Reaction times",
            "description": "One value per line or separated by spaces, commas, tabs or semicolons.",
            "type": "string",
            "maxLength": 400000,
            "default": "412 388 455 401 367 1290 395 420 140 433\n398 377 409 441 386 392 415 2405 404 399"
          },
          "unit": {
            "title": "Unit of the values",
            "type": "string",
            "enum": [
              "ms",
              "s"
            ],
            "default": "ms"
          },
          "decimalComma": {
            "title": "Values use a decimal comma (0,412)",
            "type": "boolean",
            "default": false
          },
          "minMs": {
            "title": "Faster than this is an anticipation",
            "type": "number",
            "minimum": 0,
            "maximum": 2000,
            "default": 150,
            "x-unit": "ms"
          },
          "maxMs": {
            "title": "Slower than this is a lapse",
            "type": "number",
            "minimum": 100,
            "maximum": 60000,
            "default": 3000,
            "x-unit": "ms"
          },
          "sdK": {
            "title": "SD rule: mean ± k × SD, k =",
            "type": "number",
            "minimum": 1,
            "maximum": 5,
            "default": 2.5
          },
          "madK": {
            "title": "MAD rule: median ± k × MAD, k =",
            "type": "number",
            "minimum": 1,
            "maximum": 5,
            "default": 3
          },
          "trimPercent": {
            "title": "Trimmed mean: cut from each end",
            "type": "number",
            "minimum": 0,
            "maximum": 45,
            "default": 10,
            "x-unit": "%"
          }
        },
        "required": []
      },
      "MindquarryReactionStatsResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "n",
              "skipped",
              "raw",
              "absolute",
              "sdRule",
              "madRule",
              "trimmedMean",
              "values"
            ],
            "properties": {
              "n": {
                "type": "integer"
              },
              "skipped": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "raw": {
                "type": "object"
              },
              "absolute": {
                "type": "object"
              },
              "sdRule": {
                "type": "object"
              },
              "madRule": {
                "type": "object"
              },
              "trimmedMean": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "values": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "index",
                    "ms",
                    "flags"
                  ],
                  "properties": {
                    "index": {
                      "type": "integer"
                    },
                    "ms": {
                      "type": "number"
                    },
                    "flags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}