Skip to main content

Add your description here

Project description

rlcmab-lab3-sampler

A reward sampler for Contextual Bandit news recommendation systems.

Installation

pip install rlcmab-lab3-sampler

Or install from source:

cd sampler
pip install .

Quick Start

from sampler import sampler

# Initialize with your roll number (i)
reward_sampler = sampler(i=42)

# Get a reward from arm j
reward = reward_sampler.sample(j=5)
print(reward)

# Sample a few arms
for j in range(3):
    print(j, reward_sampler.sample(j))

API Reference

sampler(i, n_arms=12)

Initialize a new sampler instance.

Parameters:

  • i (int): Student ID used to seed the random number generator
  • n_arms (int, optional): Number of arms/articles. Default: 12

Attributes:

  • means: List of mean values for each Gaussian distribution
  • stds: List of standard deviations for each Gaussian distribution
  • distributions: List of scipy.stats.norm distribution objects

sample(j)

Sample a reward from the specified arm.

Parameters:

  • j (int): Arm index (must be between 0 and 11)

Returns:

  • float: Reward value sampled from the arm's Gaussian distribution

Raises:

  • ValueError: If j is not in the valid range [0, 11]

Reproducibility

For the same student ID i, the generated arm distributions remain the same across runs. Different student IDs map to different distributions.

License

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

rlcmab_sampler-0.1.0.tar.gz (1.8 kB view details)

Uploaded Source

Built Distribution

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

rlcmab_sampler-0.1.0-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file rlcmab_sampler-0.1.0.tar.gz.

File metadata

  • Download URL: rlcmab_sampler-0.1.0.tar.gz
  • Upload date:
  • Size: 1.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rlcmab_sampler-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8ee0b54a20bd7879fff028a17c78dfdb7d0969e868e9adfe6d1e72faf9e0baf7
MD5 090d7d9c90a637719e5321f935272b16
BLAKE2b-256 e215d7be38fcbbb263c5d90bc91c2a53032bea2c3a861fdd6bc76cd624a41fd6

See more details on using hashes here.

File details

Details for the file rlcmab_sampler-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rlcmab_sampler-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rlcmab_sampler-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c80b8197cf48f092b741742862197aa1454fe10fff5bb120610538faf511f3ab
MD5 b302f0c67c0f3003a4d2759b6a693d98
BLAKE2b-256 05583de3e5833e2e4d28f55548f591c7d5c09c522af4dc74493206982cc9ea4a

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