frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

When random is not actually random enough

https://ersc.io/blog/when-random-isnt-random-enough
19•steveklabnik•4h ago

Comments

wilbo•1h ago
I got lost when OP talked about using 10 integers to choose from 3 choices. I think I figured out what was missing in the explanation.

random_u64() Mod 3 does indeed have a single bucket that is oversized. This overweights one option by about 5×10^-20.

rand() Itself has only 32767 possible values, so it's also common for a bucket to be overweighted depending on the number of buckets.

incompatible•55m ago
Makes you wonder at what point overweighting by about 5×10^-20 is something you'd want to care about.
tialaramex•56m ago
The thing you actually want is rejection sampling: https://en.wikipedia.org/wiki/Rejection_sampling.

That Wiki page makes it sound very complicated but for this purpose our implementation can be laughably simple which has the advantage that you know why it works and can maintain it properly with confidence.

Get suitably large inputs, for example if you're trying to pick integers between 2 and 11 inclusive, a nibble (half a byte) would be fine. Now, is the random input in the range you wanted? If so, you've got your answer. If not, throw this random input away and get more.

Too many programmers act as though random numbers were a precious resource.

Dylan16807•24m ago
Wow that page really gets lost in the weeds of multiple dimensions.

And yeah it's just rerolling when your random number is out of range. If you want it as simple as possible, always generate from 0-n, and grab barely enough random bits for n to fit.

fwlr•24m ago
I don’t think the “random uint” api is too low-level, or lacks a pit of success - I think you’re just reaching for the wrong api. The problem of “make n bits pseudo randomly set to either 1 or 0” is nearby to your problem of “choose an element according to a probability distribution”, but it’s a separate problem in its own right.

I think actually this is an argument for language designers to include a “std.choice” in their standard library that consumes random bytes and correctly performs common ergonomic operations like “get one element at random from this collection”.

(If your standard library tries to make a distinction between “regular random number generators” and “cryptographically secured random number generators”, I think this distinction between “generate random bits” and “make probabilistic choices” is about equally important.)

Sharing AI progress in mathematics

https://openai.com/index/sharing-ai-progress-in-mathematics/
303•OfficialTurkey•2h ago•264 comments

Mistral Large 4

https://mistral.ai/news/mistral-large-4/\
1562•Philpax•11h ago•955 comments

Decisions API is in public beta

https://developers.openai.com/api/docs/guides/decisions
114•chiefstorm•3h ago•46 comments

AnyPS5: Port PS5 binaries to PC without emulation (87% system libraries mapped)

https://github.com/boykopovar/AnyPS5
21•Fe2O3•1h ago•3 comments

Integer multiplication below n log n

https://github.com/openai/math/tree/main/preprints/Integer-multiplication-below-n-log-n-September...
28•E-Reverance•1h ago•14 comments

Penguin Mail – open-source Rust email client for Linux with AI

https://penguin-mail.com/
38•kavourias•2h ago•11 comments

EmbeddingGemma 2: An open, lightweight multimodal embedding model

https://blog.google/innovation-and-ai/technology/developers-tools/embeddinggemma-2/
203•ilreb•8h ago•28 comments

OpenAI releases 722 math manuscripts

https://github.com/openai/math/blob/main/CONTENTS.md
8•jumploops•55m ago•0 comments

Nobel Prize in Physics 2026: Francis Halzen

https://www.nobelprize.org/prizes/physics/2026/
517•solarist•14h ago•171 comments

OpenTPU – An open-source AI accelerator, developed by AI

https://github.com/FeSens/openTPU
217•fsbonetto•8h ago•282 comments

When random is not actually random enough

https://ersc.io/blog/when-random-isnt-random-enough
20•steveklabnik•4h ago•5 comments

Vibecoding Photoshop: Time and pressure

https://andreklein.net/vibecoding-photoshop-time-and-pressure/
45•samtheDamned•3h ago•46 comments

Claude Code’s suggested message feature: I think the real customer is the model

https://www.zohaib.cc/blog/smartest-claude-code-feature
80•zed_labs_dev•6h ago•43 comments

UniEvo-VL: Self-Distillation Training for Multimodal Model Self-Improvement

https://arxiv.org/abs/2609.38721
7•gmays•1h ago•0 comments

Paramount Skydance has completed its $111B merger with Warner Bros. Discovery

https://arstechnica.com/tech-policy/2026/10/paramount-completes-111b-warner-merger-creating-skyda...
160•Mgtyalx•4h ago•237 comments

LLMs may have helped my RSI

https://vaughanhilts.me/2026/10/05/llms-immensely-helped-my-rsi.html
25•vaughands•21h ago•14 comments

The Query Transformation Pipeline

https://readyset.io/blog/how-readyset-rewrites-your-sql-inside-the-query-transformation-pipeline
9•gvsg-rs•2h ago•0 comments

State of Devs 2026 survey results: developers are exhausted

https://2026.stateofdevs.com/en-US/
27•sgdesign•1h ago•7 comments

How Fast is Python 3.15?

https://blog.miguelgrinberg.com/post/how-fast-is-python-3-15
15•Qem•2h ago•8 comments

Utah to let AI examine patients and prescribe medication without human oversight

https://www.techspot.com/news/114111-utah-become-first-state-ai-examine-patients-prescribe.html
57•healsdata•7h ago•84 comments

Ask HN: Are there AI models for generating sounds based on a text and reference?

17•onemiketwelve•1d ago•4 comments

Stanford scientists found a way to regrow cartilage and stop arthritis

https://www.sciencedaily.com/releases/2026/10/261005011249.htm
20•kelnos•43m ago•2 comments

Benchmark in Milliseconds

https://matklad.github.io/2026/10/05/benchmark-milliseconds.html
126•surprisetalk•1d ago•36 comments

California closed the Montana license plate loophole

https://www.thedrive.com/news/heres-how-california-closed-the-montana-license-plate-loophole
46•speckx•7h ago•82 comments

What's Earth's dominant species by mass?

https://signoregalilei.com/2026/09/27/whats-earths-dominant-species-by-mass/
135•surprisetalk•11h ago•87 comments

Berthd

https://berthd.app/
45•handfuloflight•5h ago•62 comments

OpenSSH 10.6

https://www.openssh.org/releasenotes.html#10.6
81•torcete•3h ago•17 comments

Gleam doesn't compile to Erlang source anymore

https://gleam.run/news/gleam-doesnt-compile-to-erlang-source-anymore/
292•ingve•16h ago•122 comments

South Korea says AI agents appear to have been used to hack the country's banks

https://www.reuters.com/world/south-koreas-lee-says-ai-appears-have-been-used-bank-hacks-2026-10-06/
10•thoughtpeddler•47m ago•2 comments

Ask HN: Why is Ask HN only showing me 14 posts?

31•Gooblebrai•3h ago•31 comments