Skip to main content

A package to deal with temporal uncertainty in historical/archaeological datasets

Project description

tempun

http://doi.org/10.5281/zenodo.4650989

Citation

Vojtěch Kaše. (2022). tempun (Version v0.2). Zenodo. http://doi.org/10.5281/zenodo.4650989

Description

tempun is a Python 3 package to deal with temporal uncertainty in historical & archaeological datasets. Dating of historical artifacts (e.g. inscriptions, books etc.) is typically expressed by means of a dating interval during which it is assumed that the artifact was produced. Commonly, the production itself was much shorter than the interval and did not take more than one year. Therefore, the interval rather expresses uncertainty concerning the actual date of production. The question is how to analyze temporal trends in data revealing such temporal uncertainty.

A way forward is to use the interval to extract probability of production of the artifact. All dates (years) outside of the dating interval have probality p=0; all dates within the interval have probability somehow proportional to the duration of the interval, while the sum of probabilities for all years within the interval has to be equal to 1. This probality has to follow certain distribution. The package works with uniform or trapezoidal distribution. With uniform distribution, each year within the interval has an equal probality to be the year of production of the artifact.

We can use the intervals and the probalities associatiated with them to randomly assign individual dates (years) to each artifact within our dataset. In other words, we can model or simulate the date. We can do this repeatedly, i.e. to each artifact assign a certain number of random dates. This is in the core of a Monte Carlo Simulation (MCS) approach. In the package, it is implemented by means of model_date() function.

Having the random dates, we can proceed to do the analysis. For instance, we can recombine these dates into multiple time series and to compare between them. The package includes a bunch of functions developed for this purpose.

Getting started

The package can be installed via pip:

pip install tempun

To be sure that you have the latest version, use pip install tempun --ignore-installed. To install it directly from Jupyter, use !pip install tempun.

In Python, import the package:

import tempun

## Documentation (in progress)

model_date()

This function requires at least two parameters:

  • start
  • stop

If both start and stop are numbers, model_date(start, stop) returns a random number within the range starting with start and ending with stop.

If stop is not a valid number or contains an empty value, start is interpreted as defining a NOT BEFORE date (the so called ante quem*)

If start is not a valid number or contains an empty value, stop is interpreted as defining a NOT AFTER date (the so called post quem)

If start and stop are identical, the function returns the same number as well.

There are three optional parameters:

  • size=1: how many random numbers you want to get; by default, size=1, i.e. only one number is returned
  • b: bending point b defining shape of the trapezoidal distribution; by default, b=0, i.e. uniform distribution; set to 0.1 to get trapezoidal distribution
  • scale: scale of the half-uniform distribution used to model ante quem and post quem; by default scale=25

The function returns an individual number (if size=1; i.e. by default) or a list of numbers of length equal to size

# example 1: only start and stop
>>> tempun.model_date(-340, -330)
-337
# example 2: size specified (returns a list of numbers of given size
>>> tempun.model_date(-340, -330, 10)
[-334, -333, -332, -336, -332, -338, -333, -336, -333, -331]
# example 3: model post quem (with default scale)
>>> tempun.model_date(114, "", 10, antepost=False)
[114, 114, 114, 114, 114, 114, 114, 114, 114, 114]
>>> tempun.model_date(114, "", 10, antepost=True)
[123, 143, 123, 149, 123, 155, 125, 115, 128, 132]

get_simulation_variants()

>>> get_simulation_variants(random_dates_lists)

timeblocksplot_from_random()

>>> timeblocksplot_from_randoms(random_dates_lists, timeblocks=None, ax=None, color="black", random_size=None, **kwargs)

kdeplot_from_randoms()

>>>kdeplot_from_randoms(random_dates_lists, ax=None, color="black", random_size=None, **kwargs)

timeblocksplot_from_randoms()

>>>timeblocksplot_from_randoms(random_dates_lists, timeblocks=None, ax=None, color="black", random_size=None, **kwargs)

Version history

from numpy import trapz

  • 0.2.4 - import from scipy.stats import trapz replaced by from numpy import trapz
  • 0.2.3 - import from scipy.stats import trapz replaced by from scipy.integrate import trapz
  • 0.2.2 - minor bugs fixing
  • 0.2.1 - minor bugs fixing
  • 0.2 - numerous improvements and simplifications (some new features not compatible with previous versions...)
  • 0.1.6 - minor improvements
  • 0.1.5 - antepost argument added, default False
  • 0.1.4 - seed argument in model date
  • 0.1 - first version

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

tempun-0.2.4.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

tempun-0.2.4-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file tempun-0.2.4.tar.gz.

File metadata

  • Download URL: tempun-0.2.4.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for tempun-0.2.4.tar.gz
Algorithm Hash digest
SHA256 b6032be05b95e03807f092334731c8b0ae1fb8863e474d4e337b227821f7fcf0
MD5 d8f106cdfc98dd8c0dd61679e91b382d
BLAKE2b-256 2a5a9ef05b3c128c65f4d35cf5ed9d663df8dace000c4d73df9ca87192c5653e

See more details on using hashes here.

File details

Details for the file tempun-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: tempun-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for tempun-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 56811935db7f2b72c7d9f46d688dca843b33c5f57e4633a44ed7ff06aede4dbb
MD5 a25aefbfbca8c6a5514dcb5a11025cf4
BLAKE2b-256 abc45903c1264398c9069bbff18a7de452269828b2dd56305c059879532df477

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