Skip to content

kooltuoehias/sprite-solver

Repository files navigation

sprite-solver

A TypeScript implementation of the SPRITE (Sample Parameter Reconstruction via Iterative TEchniques) algorithm, as described by Brown & Heathers (2017).

What is SPRITE?

SPRITE is a tool used in research integrity to check the plausibility of reported summary statistics (mean and standard deviation) from a distribution of integers within a specific range.

When researchers report a mean and standard deviation for a Likert scale (e.g., 1 to 5) or any other integer-bound data, SPRITE checks if it is mathematically possible for any set of integers to produce those exact statistics simultaneously.

If SPRITE cannot find any possible distribution, it suggests that the reported statistics might be erroneous, rounded incorrectly, or potentially fabricated.

Features

  • Pure TypeScript: Zero runtime dependencies.
  • Versatile: Works in Node.js and the browser.
  • Optimized: Uses a branch-and-bound search with pruning for efficiency.
  • Precision Handling: Correctly handles floating-point rounding of reported means and standard deviations.
  • Configurable: Set custom timeouts and maximum solutions to find.

Usage

import { sprite } from '@kooltuoehias/sprite-solver';

const result = sprite({
  n: 20,          // Sample size
  mean: 3.2,      // Reported mean
  sd: 1.47,       // Reported standard deviation
  min: 1,         // Minimum possible value
  max: 5,         // Maximum possible value
  decimals: 2     // Precision of reporting (e.g., 3.20 and 1.47 have 2 decimals)
});

if (result.possible) {
  console.log('Possible distributions found:', result.solutions);
} else {
  console.log('No possible distribution found. Verdict:', result.verdict);
}

API Reference

sprite(params: SpriteParams): SpriteResult

Parameters (SpriteParams):

  • n: Sample size.
  • mean: Reported mean.
  • sd: Reported standard deviation.
  • min: Minimum possible value.
  • max: Maximum possible value.
  • decimals: Number of decimal places in reported values (used for rounding range).
  • maxSolutions (optional): Stop searching after finding this many solutions. Default: 10.
  • timeoutMs (optional): Stop searching after this many milliseconds. Default: 5000.

Returns (SpriteResult):

  • possible: Boolean indicating if at least one solution exists.
  • nSolutions: Number of solutions found.
  • solutions: Array of integer distributions (e.g., [[1, 1, 2, ...], ...]).
  • searchTime: Time taken in milliseconds.
  • verdict: 'PASS', 'FAIL', or 'TIMEOUT'.
  • explanation: Human-readable summary.

Research Integrity Context

SPRITE is often used alongside other techniques like GRIM (Granularity-Related Inconsistency of Means). While GRIM checks if the mean is consistent with the sample size, SPRITE goes further by checking if the standard deviation is also consistent with the mean and the data range.

It is particularly powerful for detecting inconsistencies in small to medium-sized samples where the constraints on integer distributions are tight.

License

MIT

References

  • Brown, N. J. L., & Heathers, J. A. J. (2017). The SPRITE Method: A Numbers-to-Numbers Redistribution Procedure for Summary Statistics and Likert Scales. Link to Preprint

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors