Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

igenerator-0.0.2.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

igenerator-0.0.2-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page