agentsclimarketplace

Probability distribution inverse sampling

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/probability-distribution-inverse-sampling

Use when when you need to reduce a large compound set generated by reaction rule application while (1) retaining compounds ranked highest by Tanimoto similarity to target structures, (2) avoiding hard thresholds that may lose borderline-useful compounds, and (3) maintaining stochastic diversity to.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill probability-distribution-inverse-sampling

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

6.9 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it

probability-distribution-inverse-sampling

Summary

Use inverse complementary cumulative distribution function (CDF) sampling to probabilistically select a fixed number of compounds from a scored population, where compounds with higher scaled similarity scores have proportionally higher selection probability. This enables stochastic filtering that preserves high-quality compounds while maintaining diversity across generations of reaction network expansion.

When to use

When you need to reduce a large compound set generated by reaction rule application while (1) retaining compounds ranked highest by Tanimoto similarity to target structures, (2) avoiding hard thresholds that may lose borderline-useful compounds, and (3) maintaining stochastic diversity to explore multiple regions of chemical space across multiple generations.

When NOT to use

  • You require deterministic, reproducible filtering: inverse sampling is stochastic and will produce different results across runs unless random seed is fixed.
  • You must guarantee that all compounds above a known threshold are retained: inverse CDF sampling can exclude high-scoring compounds if sample_size is small relative to population size.
  • You lack target compound fingerprints or Tanimoto similarity scores are not meaningful for your chemical space (e.g., scaffolds with no analogues in the target set will have near-zero scores and near-zero selection probability).

Inputs

  • compound set (SMILES strings or RDKit molecule objects)
  • target compound fingerprints (RDKit fingerprints, typically Morgan or similar)
  • sample_size (integer, number of compounds to retain)
  • weighting exponent (numeric, default 4 for T^4 scaling)

Outputs

  • filtered compound set (subset of input, size = sample_size)
  • selection probability distribution (scaled similarities used for sampling)

How to apply

For each compound in the population, compute its maximum Tanimoto similarity score to a target compound set using RDKit fingerprints. Scale each similarity score using a weighting function (default T^4, where T is the Tanimoto coefficient) to emphasize high-similarity compounds. Compute the complementary CDF (1 - CDF) of the scaled distribution, then use inverse CDF sampling to draw sample_size compounds without replacement. Compounds with higher scaled scores have higher cumulative probability mass and thus higher selection probability, but lower-ranked compounds retain a nonzero chance of selection proportional to their score.

Related tools

  • RDKit (compute Tanimoto similarity scores between compound fingerprints and apply molecular fingerprinting) — https://rdkit.org/docs/api-docs.html
  • pytest (write and execute unit tests to verify correct similarity calculation, weight scaling, and inverse CDF sampling behavior) — https://docs.pytest.org/en/stable/
  • Python (scipy or numpy) (implement inverse complementary CDF sampling and probability distribution operations)

Evaluation signals

  • Verify that compounds with higher maximum Tanimoto similarity scores have higher selection probability under the T^4 weighting function.
  • Confirm that exactly sample_size compounds are retained after filtering (no duplicates, no under/over-selection).
  • Check that the complementary CDF is correctly computed from scaled scores (i.e., CDF values are monotonically increasing from 0 to 1).
  • Validate that inverse sampling respects the scaled distribution: compounds selected multiple times across independent runs should show frequency proportional to their scaled score.
  • Test edge cases: compounds with zero similarity, empty target set, sample_size >= population size.

Limitations

  • Performance degrades for very large compound sets (>1M) due to pairwise fingerprint similarity computation; consider batch processing or approximate nearest-neighbor methods.
  • The T^4 default weighting function is arbitrary and may require tuning for different chemical spaces; weak discriminators (e.g., highly similar target set) may compress the distribution and reduce effective filtering.
  • Stochastic sampling introduces variance across runs; reproducibility requires fixed random seed, which may complicate parallel or distributed reaction network generation.
  • Inverse CDF sampling requires fully sorted or cumulative probability computation; not suitable for streaming or online filtering scenarios.

Evidence

  • [other] scales each compound's maximum Tanimoto similarity score using a weighting function (default T^4): "scales each compound's maximum Tanimoto similarity score using a weighting function (default T^4)"
  • [other] apply inverse complementary CDF sampling to select N compounds (sample_size) from the scaled distribution for the next generation: "apply inverse complementary CDF sampling to select N compounds (sample_size) from the scaled distribution for the next generation"
  • [intro] This tanimoto score is scaled and then the distribution is sampled by inverse complementary distribution function sampling to select N compounds: "This tanimoto score is scaled and then the distribution is sampled by inverse complementary distribution function sampling to select N compounds"
  • [other] compute the maximum Tanimoto similarity for each compound to the target set using RDKit fingerprints: "compute the maximum Tanimoto similarity for each compound to the target set using RDKit fingerprints"
  • [intro] Specified filters are applied before each generation (and at the end of the run if specified) to reduce the number of compounds to be expanded: "Specified filters are applied before each generation (and at the end of the run if specified) to reduce the number of compounds to be expanded"

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.