Generating random numbers faster than numpy
Project description
igenerator
igenerator is a python package that allows you to generate psudo random numbers and write them to a CSV file or SQLite database with just a few lines of code. The package utilizes the JAX function which is based on the C++ library random123. These functions are designed to be fast and efficient, and are suitable for use in machine learning applications.
Installation
You can install the package using pip:
pip install igenerator
Usage
To use the package, you first need to import it:
from igenerator import LiveGenerator
Then, you can create an instance of the TrueGenerator
class:
generator = LiveGenerator()
or
generator = LiveGenerator(0) # Pass a optional parameter (i.e any integer ) to set the seed val.
You can use the randomInt()
method to generate a list of random integers within a certain range:
result = generator.randomInt(2, 15, 4)
The above code will generate a list of 4 random integers between 2 and 15 (inclusive).
You can then use the writeCsv()
method to write the list of random numbers to a CSV file:
generator.writeCsv(result, 'your_csv_name.csv')
Note
Before writing into a csv file remember to create one with desired headers.
And use the writeSql()
method to write the list of random numbers to a SQLite database:
table_name = "your_table_name"
generator.writeSql(result,'your_database_name.db',table_name)
Note
Before writing into a sqlite database remember to create a table with desired headers.
Example :
from igenerator.generate import LiveGenerator
generator = LiveGenerator()
result = generator.randomInt(2,15,4) # For float values use randomFloat
generator.writeCsv(result,'your_csv_name.csv')
table_name = "your_table_name"
generator.writeSql(result,'your_database_name.db',table_name)
License
This package is released under the MIT License.
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
Hashes for igenerator-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0bb19ca9b87544f48421d41bb58222ea5345cb7ab040974740da5765baa0b47 |
|
MD5 | 70b3ef52b1f44e78f0d655ba079ef097 |
|
BLAKE2b-256 | 04a71d3781e85dfcd2f88e7a9b7d8c872e46884345aa5eff1dcf9d706ac1c179 |