-
Notifications
You must be signed in to change notification settings - Fork 17
Clamp probabilities passed to binomial distribution to $[0.0, 1.0]$. #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |||||
| #include "libmorton/morton3D.h" | ||||||
| #include <tuple> | ||||||
| #include <vector> | ||||||
| #include <algorithm> | ||||||
|
|
||||||
| namespace kagen { | ||||||
| class Geometric3D : public virtual Generator, private EdgeListOnlyGenerator { | ||||||
|
|
@@ -247,7 +248,7 @@ class Geometric3D : public virtual Generator, private EdgeListOnlyGenerator { | |||||
| for (SInt i = 0; i < cells_per_chunk_; ++i) { | ||||||
| seed = config_.seed + chunk_id * cells_per_chunk_ + i + total_chunks_ * cells_per_chunk_; | ||||||
| SInt h = sampling::Spooky::hash(seed); | ||||||
| SInt cell_vertices = rng_.GenerateBinomial(h, n, cell_area / total_area); | ||||||
| SInt cell_vertices = rng_.GenerateBinomial(h, n, std::clamp(cell_area / total_area, 0.0, 1.0)); | ||||||
|
||||||
| SInt cell_vertices = rng_.GenerateBinomial(h, n, std::clamp(cell_area / total_area, 0.0, 1.0)); | |
| SInt cell_vertices = rng_.GenerateBinomial(h, n, std::clamp(cell_area / total_area, LPFloat{0.0}, LPFloat{1.0})); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,7 @@ | ||||||
| #include "kagen/generators/geometric/rgg/rgg_3d.h" | ||||||
|
|
||||||
| #include <algorithm> | ||||||
|
|
||||||
| namespace kagen { | ||||||
| RGG3D::RGG3D(const PGeneratorConfig& config, const PEID rank, const PEID size) : Geometric3D(config, rank, size) { | ||||||
| // Chunk variables | ||||||
|
|
@@ -176,7 +178,8 @@ void RGG3D::GenerateCells(const SInt chunk_id) { | |||||
| for (SInt i = 0; i < cells_per_chunk_; ++i) { | ||||||
| seed = config_.seed + chunk_id * cells_per_chunk_ + i + total_chunks_ * cells_per_chunk_; | ||||||
| SInt h = sampling::Spooky::hash(seed); | ||||||
| SInt cell_vertices = rng_.GenerateBinomial(h, n, cell_area / total_area); | ||||||
| // due to potential floating point inaccuracies clamp probability | ||||||
| SInt cell_vertices = rng_.GenerateBinomial(h, n, std::clamp(cell_area / total_area, 0.0, 1.0)); | ||||||
|
||||||
| SInt cell_vertices = rng_.GenerateBinomial(h, n, std::clamp(cell_area / total_area, 0.0, 1.0)); | |
| SInt cell_vertices = rng_.GenerateBinomial(h, n, std::clamp(cell_area / total_area, LPFloat{0.0}, LPFloat{1.0})); |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |||||||
| #include "kagen/tools/postprocessor.h" | ||||||||
|
|
||||||||
| #include <iostream> | ||||||||
| #include <algorithm> | ||||||||
|
|
||||||||
| namespace kagen { | ||||||||
| PGeneratorConfig | ||||||||
|
|
@@ -188,7 +189,8 @@ void Hyperbolic<Double>::ComputeAnnuli(const SInt chunk_id) { | |||||||
|
|
||||||||
| // Variate | ||||||||
| SInt h = sampling::Spooky::hash(config_.seed + total_annuli_ * config_.k + chunk_id * total_annuli_ + i); | ||||||||
| SInt n_annulus = rng_.GenerateBinomial(h, n, ring_area / total_area); | ||||||||
| // due to potential floating point inaccuracies clamp probability | ||||||||
| SInt n_annulus = rng_.GenerateBinomial(h, n, std::clamp(ring_area / total_area, Double {0.0}, Double{1.0})); | ||||||||
|
|
||||||||
| // Push annuli_ | ||||||||
| annuli_[ComputeGlobalChunkId(i - 1, chunk_id)] = std::make_tuple(n_annulus, min_r, max_r, false, offset); | ||||||||
|
|
@@ -294,7 +296,7 @@ void Hyperbolic<Double>::GenerateCells(const SInt annulus_id, SInt chunk_id) { | |||||||
| if (!clique) | ||||||||
| seed = config_.seed + annulus_id * config_.k + chunk_id + i + config_.n; | ||||||||
| SInt h = sampling::Spooky::hash(seed); | ||||||||
|
||||||||
| SInt h = sampling::Spooky::hash(seed); | |
| SInt h = sampling::Spooky::hash(seed); | |
| // due to potential floating point inaccuracies clamp probability |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Inconsistent spacing in type construction. Line 193 uses Double {0.0} (with space), but this line uses Double{0.0} (without space). For consistency, use the same spacing convention as line 193.
| SInt n_cell = rng_.GenerateBinomial(h, n, std::clamp(grid_phi / total_phi, Double{0.0}, Double{1.0})); | |
| SInt n_cell = rng_.GenerateBinomial(h, n, std::clamp(grid_phi / total_phi, Double {0.0}, Double {1.0})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] For type safety and consistency, consider using explicit type casting for the clamp bounds. Since
cell_areaandtotal_areaare of typeLPFloat, usestd::clamp(cell_area / total_area, LPFloat{0.0}, LPFloat{1.0})to match the pattern used inhyperbolic.cppwithDouble{0.0}andDouble{1.0}.