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

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-3.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mugem-3.0.tar.gz
Algorithm Hash digest
SHA256 8a9744f04ff2db48d46c24a35381c6999451af3f9e5b6cbccf054b780771bda3
MD5 bb41092aedc1fd7dff03810792a3358b
BLAKE2b-256 f66a155f178cfd2e258cae6c8f68c18a73838f68d967151eadff1b5e53862694

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mugem-3.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-3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efd9ec644c56e98fbb4b44168bddb6c071674f26c36903af8cf2618906d4011f
MD5 9f9e9c0c401007bcfe6dbdd5f8e38c0e
BLAKE2b-256 c5146b88922896e0e02db2545b9dc92d6165ea4cc019ae4ec5d3feadacdf71e4

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