Skip to main content

Python package for Graphical Sampling Method

Project description

Graphical Sampling Method - Python Package

The Graphical Sampling Method, introduced by Panahbehagh (2025), presents an innovative approach to finite population sampling based on a unique graphical framework. This method allows researchers to visually depict first-order inclusion probabilities (FIP) as bars on a two-dimensional graph. By adjusting the positions of these bars, users can explore a wide range of sampling designs while controlling second-order inclusion probabilities (SIP).

This package, graphical_sampling, provides tools for implementing the Graphical Sampling Method and is available on PyPI.


Features

  • Create various unequal probability sampling designs with a fixed FIP.
  • Control and explore second-order inclusion probabilities (SIP) through visual manipulation.
  • Incorporate search algorithms, such as A* and Genetic Algorithm, to optimize sampling designs for specific needs (e.g., well-spread or optimal sampling).

Installation

Install the package via pip:

pip install graphical_sampling

How to Use

The package includes core classes and methods to facilitate sampling design creation and optimization. Below is a basic example demonstrating the API.

Example Usage

import graphical_sampling as gs
import numpy as np

# Set up random generator and sample data
rng = np.random.default_rng()
N = 50  # Population size
x = rng.random(size=N)  # Auxiliary variable
n = 5  # Sample size

# Generate initial inclusion probabilities
inclusion = rng.random(N)
inclusion *= n / inclusion.sum()

# Define initial sampling design and evaluation criteria
initial_design = gs.Design(inclusion)
nht = gs.criteria.VarNHT(x, inclusion)
astar = gs.search.AStar(initial_design, nht, switch_coefficient=1)

# Display initial criteria and design
print("Initial criteria value:", astar.initial_criteria_value)
astar.initial_design.show()

# Run the A* search algorithm to optimize the design
astar.run(max_iterations=2000, num_new_nodes=10, max_open_set_size=10000, num_changes=1)

# Display results after optimization
print("Best criteria value:", astar.best_criteria_value)
astar.best_design.show()

Maintainers


For more details, consult the official paper: Panahbehagh, B. (2025). Graphical Sampling Method.

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

graphical_sampling-0.1.0.tar.gz (8.9 MB view details)

Uploaded Source

Built Distribution

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

graphical_sampling-0.1.0-py3-none-any.whl (29.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: graphical_sampling-0.1.0.tar.gz
  • Upload date:
  • Size: 8.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.9

File hashes

Hashes for graphical_sampling-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c0e7f3b8f28a7a6cf12d8b2e0f966225376ea568722e6e035f4cb20505fb0fab
MD5 621b52e3f670af8cebfff02f44f17322
BLAKE2b-256 828de56ab65ac5175f3daeb0d81c7463f0c4febec2b7a91cb222b02068207686

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for graphical_sampling-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8f0879a725c0cd3e6db9e32fd12d55b132bfa5273ad258cb1c0da259609c7b8
MD5 9a82c261c3a361026f92649b609bdb8b
BLAKE2b-256 8c1161111be6c2fde207bec80a57d06aa197afb38d34eaf24961bfd7ed95a24e

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