Title: vector_of_kll_floats_sketches.get_quantiles() returns wrong values with float32 · Issue #63 · apache/datasketches-python · GitHub
Open Graph Title: vector_of_kll_floats_sketches.get_quantiles() returns wrong values with float32 · Issue #63 · apache/datasketches-python
X Title: vector_of_kll_floats_sketches.get_quantiles() returns wrong values with float32 · Issue #63 · apache/datasketches-python
Description: #!/usr/bin/env python3 """ Minimal example: vector_of_kll_floats_sketches.get_quantiles() returns WRONG VALUES with float32 """ import numpy as np from datasketches import vector_of_kll_floats_sketches # Create test data: 1000 samples be...
Open Graph Description: #!/usr/bin/env python3 """ Minimal example: vector_of_kll_floats_sketches.get_quantiles() returns WRONG VALUES with float32 """ import numpy as np from datasketches import vector_of_kll_floats_sket...
X Description: #!/usr/bin/env python3 """ Minimal example: vector_of_kll_floats_sketches.get_quantiles() returns WRONG VALUES with float32 """ import numpy as np from datasketches im...
Opengraph URL: https://github.com/apache/datasketches-python/issues/63
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"vector_of_kll_floats_sketches.get_quantiles() returns wrong values with float32","articleBody":"\n\n```python\n#!/usr/bin/env python3\n\"\"\"\nMinimal example: vector_of_kll_floats_sketches.get_quantiles() returns WRONG VALUES with float32\n\"\"\"\nimport numpy as np\nfrom datasketches import vector_of_kll_floats_sketches\n\n# Create test data: 1000 samples between -100 and -10\nnp.random.seed(42)\ntest_data = np.random.uniform(-100, -10, size=(1000, 1)).astype(np.float32)\n\nprint(\"Test data: 1000 samples between -100 and -10\")\nprint(f\"True min: {test_data.min():.2f}, True max: {test_data.max():.2f}\")\n\n# Create sketch and add data\nkll = vector_of_kll_floats_sketches(200, 1)\nkll.update(test_data)\n\n# Request p0.0001 (should be ~-100) and p0.9999 (should be ~-10)\nranks_list = [0.0001, 0.9999]\nranks_array32 = np.array(ranks_list, dtype=np.float32)\nranks_array64 = np.array(ranks_list, dtype=np.float64)\n\n\nprint(\"\\n\" + \"=\"*60)\nprint(\"BUG: numpy array with dtype=np.float32 returns WRONG quantiles\")\nprint(\"=\"*60)\n\nquants_array = kll.get_quantiles(ranks_array32)\nprint(f\"\\nWith numpy array with dtype=np.float32: {ranks_array32}\")\nprint(f\" p0.0001 = {quants_array[0][0]:.2f} (expected: ~-100)\")\nprint(f\" p0.9999 = {quants_array[0][1]:.2f} (expected: ~-10)\")\nprint(f\" ✗ WRONG: Both values near minimum!\")\n\nquants_array64 = kll.get_quantiles(ranks_array64)\nprint(f\"\\nWith numpy array with dtype=np.float64: {ranks_array64}\")\nprint(f\" p0.0001 = {quants_array64[0][0]:.2f} (expected: ~-100)\")\nprint(f\" p0.9999 = {quants_array64[0][1]:.2f} (expected: ~-10)\")\nprint(f\" ✓ CORRECT\")\n\n```\n\n```\nTest data: 1000 samples between -100 and -10\nTrue min: -99.58, True max: -10.03\n\n============================================================\nBUG: numpy array with dtype=np.float32 returns WRONG quantiles\n============================================================\n\nWith numpy array with dtype=np.float32: [1.000e-04 9.999e-01]\n p0.0001 = -98.69 (expected: ~-100)\n p0.9999 = -99.50 (expected: ~-10)\n ✗ WRONG: Both values near minimum!\n\nWith numpy array with dtype=np.float64: [1.000e-04 9.999e-01]\n p0.0001 = -99.50 (expected: ~-100)\n p0.9999 = -10.28 (expected: ~-10)\n ✓ CORRECT\n```","author":{"url":"https://github.com/tyler-rt","@type":"Person","name":"tyler-rt"},"datePublished":"2025-12-01T07:45:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/63/datasketches-python/issues/63"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bbd9e381-56d4-05dd-ff89-c2c7c2775fc7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E16C:1FA359:460DE0:5DB04E:698F748D |
| html-safe-nonce | 92e5a97a5e66bd929891e0afc84b55a7a00d6818eb1c31a843b775e891c96303 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTZDOjFGQTM1OTo0NjBERTA6NURCMDRFOjY5OEY3NDhEIiwidmlzaXRvcl9pZCI6IjM3MjM2NzgzNTYxMDY4Njc4NTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | dec05ca136113013f39ba916fd13cab3b3ce549730ff1a86e838f429c6079db0 |
| hovercard-subject-tag | issue:3679703646 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/apache/datasketches-python/63/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2c743650b58f80df1696887b8403a72da4ada42ed39b2820604db15946fe9e65/apache/datasketches-python/issues/63 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2c743650b58f80df1696887b8403a72da4ada42ed39b2820604db15946fe9e65/apache/datasketches-python/issues/63 |
| og:image:alt | #!/usr/bin/env python3 """ Minimal example: vector_of_kll_floats_sketches.get_quantiles() returns WRONG VALUES with float32 """ import numpy as np from datasketches import vector_of_kll_floats_sket... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tyler-rt |
| hostname | github.com |
| expected-hostname | github.com |
| None | a40913be56b49e6322246e4bcd65ab6ec4b458c6dca6b691d30419da1e5ee35e |
| turbo-cache-control | no-preview |
| go-import | github.com/apache/datasketches-python git https://github.com/apache/datasketches-python.git |
| octolytics-dimension-user_id | 47359 |
| octolytics-dimension-user_login | apache |
| octolytics-dimension-repository_id | 685709717 |
| octolytics-dimension-repository_nwo | apache/datasketches-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 685709717 |
| octolytics-dimension-repository_network_root_nwo | apache/datasketches-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ca6051e0ba2303370981e3d01e2bc1044eb3b429 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width