A library for testing pseudo-noise (PN) sequences.
Project description
pn-cho
A Python library for testing pseudo-noise (PN) sequences
Install
pip install pn-cho
Developing
poetry install
eval $(poetry env activate)
python
# Inside REPL
import pn_sequence
pn_sequence.is_first_postulate_true("011001000111101") # etc.
Testing
poetry run pytest
For coverage:
poetry run pytest --cov=pn_sequence tests/
Contributing
Contributions are welcome. Please fork the project and use feature a feature branch. For bugs and suggestions, please open an issue.
License
The project is licensed under the GNU Lesser General Public License. See LICENSE for full terms.
Golomb's randomness postulates
Golomb's randomness postulates describe properties that can be found in a random sequence. A periodic binary sequence that satisfies all three postulates is a pseudo-noise (PN) or pseudo-random sequence -- it has noise-like properties and appears random, even though it was generated deterministically. PN sequences can be used for various applications, including signal synchronization, navigation, radar ranging, random number generation, spread-spectrum communications, and cryptography (Helleseth and Kumar, 1999).
E.g.: Take sequence 0011101.
Postulate 1
In the cycle s^N of s, the number of 1's differs from the number of 0's by at most 1 (Menezes, Van Oorschot and Vanstone, 2018)
Count 1's and 0's:
N_0 = 3
N_1 = 4
Find the difference:
|N_0 - N_1| = |3 - 4| = 1
The first postulate is satisfied.
Postulate 2
In the cycle, at least half the runs have length 1, at least one-fourth have length 2, at least one-eighth have length 3, etc., as long as the number of runs so indicated exceeds 1. (Menezes, Van Oorschot and Vanstone, 2018)
Mark and count runs:
00 | 111 | 0 | 1
Calculate run lengths:
Run | Length
---------------
00 | 2
111 | 3
0 | 1
1 | 1
For a sequence with 4 runs, the the required number of runs is as follows:
Run length | Number of runs
---------------------------
1 | 4 / 2 = 2
2 | 4 / 4 = 1
3 | 4 / 8 = 0.5
We have 2 runs of length 1, 1 run of length 2, and 1 run of length 3. Now compare actual number of runs with required:
Length | Actual | Required
--------------------------
1 | 2 | 2.00
2 | 1 | 1.00
3 | 1 | 0.50
All runs pass the requirement. The second postulate is satisfied.
Postulate 3
The autocorrelation function C(t) is two-valued. (Menezes, Van Oorschot and Vanstone, 2018)
In other words, when the sequence is compared with shifted versions of itself, it either correlates perfectly (at zero shift) or maintains a constant correlation at all other shifts.
Shift 0: 0|0|1|1|1|0|1
0|0|1|1|1|0|1
-------------
Difference: = 0 bits
Shift 1: 0|0|1|1|1|0|1
1|1|1|0|1|0|0
^ ^ ^ ^
Difference: = 4 bits
Shift 2: 0|1|1|1|0|1|0
1|1|1|0|1|0|0
^ ^ ^ ^
Difference: = 4 bits
Shift 3: 1|1|1|0|1|0|0
1|1|0|1|0|0|1
^ ^ ^ ^
Difference: = 4 bits
Shift 4: 1|1|0|1|0|0|1
1|0|1|0|0|1|1
^ ^ ^ ^
Difference: = 4 bits
Shift 5: 1|0|1|0|0|1|1
0|1|0|0|1|1|1
^ ^ ^ ^
Difference: = 4 bits
Shift 6: 0|1|0|0|1|1|1
1|0|0|1|1|1|0
^ ^ ^ ^
Difference: = 4 bits
Constant Hamming distance for all non-zero shifts means the second value of the autocorrelation function is constant as well. Thus, the third postulate is satisfied.
References
- Menezes, A.J., Van Oorschot, P.C. and Vanstone, S.A. (2018) Handbook of Applied Cryptography. 1st edn. CRC Press. Available at: https://doi.org/10.1201/9780429466335.
- Pinaki, M. (no date) ‘Golomb’s Randomness Postulates’. Available at: https://www.iitg.ac.in/pinaki/Golomb.pdf.
- Helleseth, T., Kumar, P.V. (1999) “Pseudonoise Sequences” Mobile Communications Handbook Ed. Suthan S. Suthersan Boca Raton: CRC Press LLC
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pn_cho-0.1.0.tar.gz.
File metadata
- Download URL: pn_cho-0.1.0.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.13.5 Linux/6.12.41+deb13-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f5b23dfd63a9e926f8f34f7cd0d2f043f39448af50911b12a5004b887934bfe
|
|
| MD5 |
562e6367fd70179421c70a78dedda775
|
|
| BLAKE2b-256 |
812c904612dbc4457f2e53cede19ef548d28624c65a182f98ca2b07a0fac60e1
|
File details
Details for the file pn_cho-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pn_cho-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.13.5 Linux/6.12.41+deb13-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2303729eba6c923a655a991d31381c44743da048dc83f4743d212c5aa11c7fc
|
|
| MD5 |
a545561a23a89bfa21f7230fadc4264c
|
|
| BLAKE2b-256 |
cddbaf68b6b30524a7a1fb5689c79a18345bd05d79a8a0a20454703746b4a84a
|