Skip to main content

Python package for Geometric Sampling Method

Project description

Geometric Sampling Method - Python Package

The Geometric Sampling Method, introduced by Panahbehagh (2024), presents an innovative approach to finite population sampling based on a unique geometric 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, geometric_sampling, provides tools for implementing the Geometric 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 geometric_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 geometric_sampling as gm
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 = gm.Design(inclusion)
nht = gm.criteria.VarNHT(x, inclusion)
astar = gm.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(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. (2024). Geometric 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

geometric_sampling-0.4.1.tar.gz (112.9 kB view details)

Uploaded Source

Built Distribution

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

geometric_sampling-0.4.1-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file geometric_sampling-0.4.1.tar.gz.

File metadata

  • Download URL: geometric_sampling-0.4.1.tar.gz
  • Upload date:
  • Size: 112.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.29

File hashes

Hashes for geometric_sampling-0.4.1.tar.gz
Algorithm Hash digest
SHA256 44a1ad1de2dc419dcf8cf470c13d7188f8504ccc01927f84855a94a901f60e1b
MD5 cbbff55503a0340b90b96111ed24a8d7
BLAKE2b-256 846d15450f3df48a68a66e5ccff45b848262f33ee1a317177ac6659af772225b

See more details on using hashes here.

File details

Details for the file geometric_sampling-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for geometric_sampling-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 86ac67f2896af662b284c17e8f0ca8cb281d0ca75e22e3ebddd7a7e1329f6547
MD5 d6f2a1ae59b6298ac1f381cfe850cc5e
BLAKE2b-256 76d62f8f874f7d90b546d315181b081fb78cc5187d1f40a20640f4356b67480c

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