Some simple useful math equations.
Project description
My equations (myeq)
Some simple useful math equations.
Distance
Equation to measure distances between values.
Inverse normalized sigmoid
from myeq.distance import inv_norm_sigmoid
def inv_norm_sigmoid(x: float, s: float = 0.3, t: float = 0.88, p: float = 3.3, adjust: bool = False) -> float:
This function is used to normalize a value that represents a distance using an inverted sigmoid function as following:
I usually use this function to normalize the Levenshtein or another edition distance that is not normalized. This way, when the distance is small, the value is very close to 1, in the middle the value decreases very fast, but far away the velocity of decrease goes slower with the limit to 0. In the Levenshtein algorithm, this means that when the difference is small, the similarity value is very close to 1. But it quickly decreases when there are more text editions.
You can adjust the function parameters using the Inverse Normalized Sigmoid Demos web page.
Examples of usage:
from myeq.distance import inv_norm_sigmoid
print(inv_norm_sigmoid(0)) # Almost 1: 0.9999853027487737)
print(inv_norm_sigmoid(1)) # Close to 1: 0.9999910856079368)
print(inv_norm_sigmoid(3)) # Start to reduce quickly: 0.7633315491944042)
print(inv_norm_sigmoid(5)) # Very low: 0.12000003643145052)
The adjust parameter is to force the value 1 when the distance is 0, for example:
from myeq.distance import inv_norm_sigmoid
print(inv_norm_sigmoid(0, adjust=True)) # Exactly 1.0)
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
File details
Details for the file myeq-0.0.4.tar.gz
.
File metadata
- Download URL: myeq-0.0.4.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ecec7cbb572946535557ddcfcc6d625783ea146b1497122b1c8a72ba6a7b829 |
|
MD5 | d3798a7245a42c0930f05571c475dadd |
|
BLAKE2b-256 | 1e776f850fc11dd89e76a9aa8d15ae45114ad97b1fa80129aabc4eb5e51445df |