Skip to main content

An implementation of the GRIM test, in Python

Project description

The GRIM test

An implementation of the GRIM test, in python

Beta: Work in progress

Introduction

This package is based on the GRIM (Granularity-Related Inconsistency of Means) test first highlighted by Heathers & Brown in their 2016 paper.

The test makes use of a simple numerical property to identify if the mean of integer values has been correctly calculated.

You don't need the original integer values. You just need the mean and the number (n) of items.

What about rounding?

Often the mean you are testing has previously been rounded. You can check if the mean is consistent with a particular rounding type by including that as an argument.

This implementation supports all the rounding types currently found in Python 3.8's decimal implementation.

(They are: ROUND_CEILING, ROUND_DOWN, ROUND_FLOOR, ROUND_HALF_DOWN, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_UP, ROUND_05UP)

If no rounding type is included then the test assumes ROUND_HALF_UP.

Example: Is this mean, n and rounding type consistent?

from grim import mean_tester
import decimal

# mean is 11.09 and n is 21
print(mean_tester.consistency_check('11.09', '21', decimal.ROUND_HALF_UP))

This will return False as the mean could not be correct given a list of 21 integers (and using ROUND_HALF_UP rounding.)

Example: Is this mean & n consistent using any rounding type?

from grim import mean_tester
import decimal

# mean is 11.09 and n is 21
print(mean_tester.summary_consistency_check('11.09', '21'))

This will return:

{'ROUND_CEILING': False, 'ROUND_DOWN': True, 'ROUND_FLOOR': True, 'ROUND_HALF_DOWN': False, 'ROUND_HALF_EVEN': False, 'ROUND_HALF_UP': False, 'ROUND_UP': False, 'ROUND_05UP': True}

As you can see, a given mean and n might be consistent using one form of rounding but not others.

You can pass in the numbers as Strings or Decimals, this avoids floating point accuracy issues that are more likely to occur when using a 'float'.

Warning:

  1. Beware of creating Decimals from floating point numbers as these may have floating point inaccuracies.

How can I find out more about the GRIM test?

James Heathers has published articles that explain how the technique works and how he used it to expose inconsistencies in scientific papers.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grim-0.1.2.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grim-0.1.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file grim-0.1.2.tar.gz.

File metadata

  • Download URL: grim-0.1.2.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5

File hashes

Hashes for grim-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e8a2edcacf68e253dbb21efcbf71c46d8e04bac37a89eaafbc37f6a4785bbf08
MD5 6ae071686d8a1e782600bd7881f91d14
BLAKE2b-256 955d309fd9a5825ce18fc7b5b5dbf6cc399a7d033a6d3068fc5f3bc8f2912036

See more details on using hashes here.

File details

Details for the file grim-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: grim-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5

File hashes

Hashes for grim-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9d8a774e129379ac086f1f3b4fa84c87251f88fce7c6e0352a9299b26318594a
MD5 6baaa39b4deb78dac02e2d017b6d93d0
BLAKE2b-256 85dfb09d969cf3ebf2af97be07c3f4fac0c327aa9974bb7fa932b057de1931b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page