Skip to main content

Multiplicative Generative Method (MGM)

Project description

Mugem

Mugem (Multiplicative Generative Method) is a lightweight Python package that generates pseudo-random numbers using the Multiplicative Congruential Method (MCM). it is widely used random number generation algorithm defined by the recurrence relation:

It returns both the raw sequence of generated numbers and their normalized versions between [0, 1) using NumPy.


Features

  • Easy-to-use function interface
  • Pure Multiplicative Congruential Method (no increment term)
  • Fast random number generation
  • Normalized output with NumPy
  • User-defined input parameters

Installation

Install via pip:

pip install mugem

(Use after publishing to PyPI)


Usage

from mugem import mgm

# Define parameters
a = 2        # Multiplier
x0 = 5       # Seed value
m = 103      # Modulus
count = 10   # Number of values

# Generate pseudo-random numbers
y, u = mgm(a, x0, m, count)

print("Generated:", y)
print("Normalized:", u)

Function Reference

def mgm(a: int, x0: int, m: int, count: int = 10):
    """
    Multiplicative Congruential Method (MCM) to generate pseudo-random numbers.

    Parameters:
        a (int): Multiplier
        x0 (int): Initial seed value
        m (int): Modulus
        count (int): Total numbers to generate

    Returns:
        tuple:
            y (list): Raw generated integers
            u (ndarray): Normalized values in [0, 1)
    """

Example Script

from mugem import mgm

a, x0, m, count = 2, 5, 103, 10
y, u = mgm(a, x0, m, count)

print("Generated Sequence:", y)
print("Normalized Sequence:", u)

Author

Rohit Kumar Behera

📧 Email: rohitmbl24@gmail.com

PyPI: [https://pypi.org/project/mgm/]


Feel free to contribute, suggest improvements, or report issues.

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

mugem-2.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

mugem-2.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file mugem-2.0.tar.gz.

File metadata

  • Download URL: mugem-2.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for mugem-2.0.tar.gz
Algorithm Hash digest
SHA256 4e3941c156f45025db7e759d091c90a215b07a20e2342886cb0387f68c41a4a8
MD5 5b6abcdb3707e9eca857b1d6f08c991f
BLAKE2b-256 3dba477b4d80bdedff1785362eded6c3187e044c432646d2be621bf2102598ee

See more details on using hashes here.

File details

Details for the file mugem-2.0-py3-none-any.whl.

File metadata

  • Download URL: mugem-2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for mugem-2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d908b947836dac945d1fc32ecb54bdda8274ea2eaa26e56a80642c19afaa987
MD5 81d81adaf1933d5d66fef73f3adf77da
BLAKE2b-256 20b35db4b5e572a437a69bcee9ab923a6bcbe298ad55b54c7077d827c3df3f41

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