Skip to main content

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:

Inverse Normalized Sigmoid

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

myeq-0.0.4.tar.gz (2.7 kB view hashes)

Uploaded Source

Supported by

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