Skip to main content

Modelling of quantitative state changes as step functions

Project description

staircase logo

The leading use-case for the staircase package is for the creation and analysis of step functions.

Pretty exciting huh.

But don't hit the close button on the browser just yet. Let us convince you that much of the world around you can be modelled as step functions.

For example, the number of users viewing this page over time can be modelled as a step function. The value of the function increases by 1 every time a user arrives at the page, and decreases by 1 every time a user leaves the page. Let's say we have this data in vector format (i.e. tuple, list, numpy array, pandas series). Specifically, assume arrive and leave are vectors of times, expressed as minutes past midnight, for all page views occuring yesterday. Creating the corresponding step function is simple. To achieve it we use the Stairs class:

import staircase as sc

views = sc.Stairs()
views.layer(arrive,leave)

We can visualise the function with the plot function:

views.plot()

pageviews example

We can find the total time the page was viewed:

views.integrate(0,1440)

We can find the average number of viewers:

views.mean(0,1440)

We can find the average number of viewers for each hour of the day:

[views.mean(60*i, 60*(i+1)) for i in range(24)]

We can find the maximum concurrent views:

views.max(0,1440)

There is plenty more analysis that could be done. The staircase package provides a rich variety of arithmetic operations, relational operations, logical operations, for use with Stairs, in addition to functions for univariate analysis, aggregations and compatibility with pandas.Timestamp.

Installation

Staircase can be installed from PyPI:

pip install staircase

or also with conda:

conda install -c venaturum staircase

Documentation

The complete guide to using staircase can be found at Read the Docs

Contributing

Please stay tuned for how you can contribute...

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

  • This project is heavily reliant on sorted containers. Grant Jenks has done a great job bringing this functionality to Python at lightning fast speeds.
  • staircase began development from within the Hunter Valley Coal Chain Coordinator. Thanks for the support!

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

staircase-0.4.4-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file staircase-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: staircase-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.42.0 CPython/3.7.5

File hashes

Hashes for staircase-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bbf612c19af4a1eb470e04353b21307992753cafaa7aef6510eda7b3f84a2fff
MD5 76a4b8e5be689785a2606d8dea829344
BLAKE2b-256 3a551f00e6a7a05042a2fd1f92715c808297b52b7bf4ba4664059a932cc981d9

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