public static class DeterministicGrouping { public static bool IsSelected(Guid entropy, ulong numerator, ulong denominator = 100) { if(numerator > denominator) throw new ArgumentOutOfRangeException(nameof(numerator), "The numerator cannot be larger than the denominator."); if (numerator <= 0) throw new ArgumentOutOfRangeException(nameof(numerator), "The numerator must be a positive non-zero value."); if (denominator <= 0) throw new ArgumentOutOfRangeException(nameof(denominator), "The denominator must be a positive non-zero value."); ulong guidNumericValue = BitConverter.ToUInt32(entropy.ToByteArray().Take(4).ToArray(), 0); return guidNumericValue%denominator < numerator; } }