TimeComplex


NameTimeComplex JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://github.com/hodge-py/TimeComplex
SummaryBig O calculations for Time
upload_time2024-01-22 18:51:15
maintainer
docs_urlNone
authorKarson Hodge
requires_python
licenseCopyright
keywords bigo algorithm calculations
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TimeComplex

This package was created to evaluate functions for time complexity. The function runs an algorithm over and over with randomized input sizes to judge the time complexity.
PYPI:
<https://pypi.org/project/SpaceTimeComplex/>

## Example

```python

def looper2(n):
    for x in range(n):
        print(x)

def testone(n):
    for x in range(len(n)):
        for y in range(len(n)):
            for z in range(len(n)):
              two = y
              one = x
              three = z

def looper(today,stringer):
    for x in range(today):
        print(x)
    
    for y in stringer:
        print(y)



def logfunc(n):
    for x in range(0,len(n[0]),20):
        print(x) 


def binary_search(array,target):
  low = 0
  high = len(array) - 1
  while low <= high:
    mid = (low + high) // 2 # integer division
    element = array[mid]
    if element == target:
      return mid
    elif element < target:
      low = mid + 1
    else:
      high = mid - 1
  return -1


real = SpaceTimeComplex.RealTime() # Create the class
#x.realTimeComplex(stmt="looper(10)",value=10)

testSet = real.generateTestSet(size2=100) #generate a test set

testSet1 = [[4,"stnr=gwege"], [12,"sagsdgg"], [3,"esfsfsseafesfsefsef"], [45,"stnrefgseege"], [17,"sagwetjtwfwe"], [34,"esfsfssem"],[41,"stn"], [53,"sakhhksdgg"], [24,"esjfjkkfsefsef"], [70,"stnwete"], [7,"sagwefwewsdfsdffwe"] ] 
# format of array. 2d array with each test set inside. You can make your own or just generate one with generateTestSet()

logFunction, SlopeConst = real.complexGuess(testone,testSet) #guess the complexity of a function. Returns the guess and a plot

ratio = real.bestWorst(testone,testSet)

```

![figureex](https://github.com/hodge-py/TimeComplex/assets/105604814/a59a49ab-1aa3-48d6-80e3-fe3d68ef33f5)

![firgurehist](https://github.com/hodge-py/TimeComplex/assets/105604814/48ac6f25-91ac-4163-adac-5cfe8f8c710c)

![finaloutput](https://github.com/hodge-py/TimeComplex/assets/105604814/97450568-cd8f-4a6d-9c6c-d666dfa6c9c8)

## Example of the non-log function graphed using the derived power. $O(n^{2.8})$

![grapher](https://github.com/hodge-py/TimeComplex/assets/105604814/028554a6-36c5-431f-b1ba-58bdd0a23223)

This is in respects to time (ms). When accounting for just the growth of input, the input will grow in a polynomial fashion.

## Math behind the calculations

A simplistic understanding how the time complexity is extracted stems from the log power rule.

Power Rule:

$log(n^k) = k \cdot log(n)$

After apply a log to both n and y variables, a linear regression is applied.

$y = time, n = input size, b = constant$

$log(y) = log(n^k) + b$

apply the power rule

$log(y) = k \cdot log(n) + b$

Everything can be ignored except for k. k determines the slope of line and tells us the time complexity.

$time complexity = N^k$

## Jupyter Lab

The package can also be used in jupyter notebooks.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hodge-py/TimeComplex",
    "name": "TimeComplex",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "BigO,Algorithm,Calculations",
    "author": "Karson Hodge",
    "author_email": "khodge1@hotmail.com",
    "download_url": "https://files.pythonhosted.org/packages/af/07/d3023c58b9e9e410fc6359380557ba3537ab51475656fb68645b1841bafa/TimeComplex-0.0.1.tar.gz",
    "platform": null,
    "description": "# TimeComplex\r\n\r\nThis package was created to evaluate functions for time complexity. The function runs an algorithm over and over with randomized input sizes to judge the time complexity.\r\nPYPI:\r\n<https://pypi.org/project/SpaceTimeComplex/>\r\n\r\n## Example\r\n\r\n```python\r\n\r\ndef looper2(n):\r\n    for x in range(n):\r\n        print(x)\r\n\r\ndef testone(n):\r\n    for x in range(len(n)):\r\n        for y in range(len(n)):\r\n            for z in range(len(n)):\r\n              two = y\r\n              one = x\r\n              three = z\r\n\r\ndef looper(today,stringer):\r\n    for x in range(today):\r\n        print(x)\r\n    \r\n    for y in stringer:\r\n        print(y)\r\n\r\n\r\n\r\ndef logfunc(n):\r\n    for x in range(0,len(n[0]),20):\r\n        print(x) \r\n\r\n\r\ndef binary_search(array,target):\r\n  low = 0\r\n  high = len(array) - 1\r\n  while low <= high:\r\n    mid = (low + high) // 2 # integer division\r\n    element = array[mid]\r\n    if element == target:\r\n      return mid\r\n    elif element < target:\r\n      low = mid + 1\r\n    else:\r\n      high = mid - 1\r\n  return -1\r\n\r\n\r\nreal = SpaceTimeComplex.RealTime() # Create the class\r\n#x.realTimeComplex(stmt=\"looper(10)\",value=10)\r\n\r\ntestSet = real.generateTestSet(size2=100) #generate a test set\r\n\r\ntestSet1 = [[4,\"stnr=gwege\"], [12,\"sagsdgg\"], [3,\"esfsfsseafesfsefsef\"], [45,\"stnrefgseege\"], [17,\"sagwetjtwfwe\"], [34,\"esfsfssem\"],[41,\"stn\"], [53,\"sakhhksdgg\"], [24,\"esjfjkkfsefsef\"], [70,\"stnwete\"], [7,\"sagwefwewsdfsdffwe\"] ] \r\n# format of array. 2d array with each test set inside. You can make your own or just generate one with generateTestSet()\r\n\r\nlogFunction, SlopeConst = real.complexGuess(testone,testSet) #guess the complexity of a function. Returns the guess and a plot\r\n\r\nratio = real.bestWorst(testone,testSet)\r\n\r\n```\r\n\r\n![figureex](https://github.com/hodge-py/TimeComplex/assets/105604814/a59a49ab-1aa3-48d6-80e3-fe3d68ef33f5)\r\n\r\n![firgurehist](https://github.com/hodge-py/TimeComplex/assets/105604814/48ac6f25-91ac-4163-adac-5cfe8f8c710c)\r\n\r\n![finaloutput](https://github.com/hodge-py/TimeComplex/assets/105604814/97450568-cd8f-4a6d-9c6c-d666dfa6c9c8)\r\n\r\n## Example of the non-log function graphed using the derived power. $O(n^{2.8})$\r\n\r\n![grapher](https://github.com/hodge-py/TimeComplex/assets/105604814/028554a6-36c5-431f-b1ba-58bdd0a23223)\r\n\r\nThis is in respects to time (ms). When accounting for just the growth of input, the input will grow in a polynomial fashion.\r\n\r\n## Math behind the calculations\r\n\r\nA simplistic understanding how the time complexity is extracted stems from the log power rule.\r\n\r\nPower Rule:\r\n\r\n$log(n^k) = k \\cdot log(n)$\r\n\r\nAfter apply a log to both n and y variables, a linear regression is applied.\r\n\r\n$y = time, n = input size, b = constant$\r\n\r\n$log(y) = log(n^k) + b$\r\n\r\napply the power rule\r\n\r\n$log(y) = k \\cdot log(n) + b$\r\n\r\nEverything can be ignored except for k. k determines the slope of line and tells us the time complexity.\r\n\r\n$time complexity = N^k$\r\n\r\n## Jupyter Lab\r\n\r\nThe package can also be used in jupyter notebooks.\r\n",
    "bugtrack_url": null,
    "license": "Copyright",
    "summary": "Big O calculations for Time",
    "version": "0.0.1",
    "project_urls": {
        "Download": "https://github.com/hodge-py/TimeComplex/releases",
        "Homepage": "https://github.com/hodge-py/TimeComplex"
    },
    "split_keywords": [
        "bigo",
        "algorithm",
        "calculations"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af07d3023c58b9e9e410fc6359380557ba3537ab51475656fb68645b1841bafa",
                "md5": "753219e6ce683369c6ed6df6e999f3e8",
                "sha256": "ab50467f75b8e1ef21be775d01a9e510f3917b940b56457590a0fb38b2f813f5"
            },
            "downloads": -1,
            "filename": "TimeComplex-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "753219e6ce683369c6ed6df6e999f3e8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5726,
            "upload_time": "2024-01-22T18:51:15",
            "upload_time_iso_8601": "2024-01-22T18:51:15.799265Z",
            "url": "https://files.pythonhosted.org/packages/af/07/d3023c58b9e9e410fc6359380557ba3537ab51475656fb68645b1841bafa/TimeComplex-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-22 18:51:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hodge-py",
    "github_project": "TimeComplex",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "timecomplex"
}
        
Elapsed time: 0.16632s