semvec/pypi-packages huggingface dataset:
brnldist 1.0.0
Generate Bernoulli distributed values using Linear Congruential Generator (LCG)
License: MIT
Requires Python: >=3.6

---

## 📌 Description

### Generate Bernoulli Distributed Values using Linear Congruential Generator (LCG)

`brnldist` is a lightweight Python package that simulates **Bernoulli-distributed random variables** using values generated by a **Linear Congruential Generator (LCG)**.

It combines the simplicity of LCG for pseudo-random number generation with a Bernoulli distribution threshold to produce a sequence of `0`s and `1`s.

This is useful for simulations, basic statistical modeling, or understanding how pseudo-random processes work behind random variable generation.

---

### ⚙️ How It Works

1. Uses LCG to generate a sequence of pseudo-random integers:

   $$
   X_{n+1} = (a \cdot X_n + c) \mod m
   $$

2. Normalizes each LCG value to the interval \[0, 1] by dividing by the modulus `m`.

3. Compares each normalized value with a probability threshold `p`:

   * If the value < `p` → return `1` (success)
   * Else → return `0` (failure)

4. Returns a sequence of binary outcomes following a **Bernoulli(p)** distribution.

---

### 📈 Example Output

```python
from brnldist import brnldist
from brnldist import lcg
a=2
c=3
x0=5
m=103
p=0.5
n=10
y, u, x = lcg(a, c, x0, m, p, n)

#Parameters:
        #a (int): LCG multiplier
        #c (int): LCG increment
        #x0 (int): Seed value
        #m (int): LCG modulus
        #p (float): Bernoulli threshold (0 to 1)
        #n (int): Number of values to generate
print("LCG raw values (y):", y)
print("Normalized values (u):", u)
print("Second normalized value u[1]",u[1])
print("Bernoulli output (x):", x)

# y = LCG raw values
# u = normalized values
# u[1] = Second normalized value
# x = Bernoulli (0 or 1) outcomes
```
👤 Author
Rohit Kumar Behera
📧 Email: rohitmbl24@gmail.com
🌐 GitHub: github.com/muinrohit
🏠 Location: Odisha, India

---