frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Convert tempo (BPM) to millisecond durations for musical note subdivisions

https://brylie.music/apps/bpm-calculator/
1•brylie•1m ago•0 comments

Show HN: Tasty A.F.

https://tastyaf.recipes/about
1•adammfrank•2m ago•0 comments

The Contagious Taste of Cancer

https://www.historytoday.com/archive/history-matters/contagious-taste-cancer
1•Thevet•3m ago•0 comments

U.S. Jobs Disappear at Fastest January Pace Since Great Recession

https://www.forbes.com/sites/mikestunson/2026/02/05/us-jobs-disappear-at-fastest-january-pace-sin...
1•alephnerd•4m ago•0 comments

Bithumb mistakenly hands out $195M in Bitcoin to users in 'Random Box' giveaway

https://koreajoongangdaily.joins.com/news/2026-02-07/business/finance/Crypto-exchange-Bithumb-mis...
1•giuliomagnifico•4m ago•0 comments

Beyond Agentic Coding

https://haskellforall.com/2026/02/beyond-agentic-coding
2•todsacerdoti•5m ago•0 comments

OpenClaw ClawHub Broken Windows Theory – If basic sorting isn't working what is?

https://www.loom.com/embed/e26a750c0c754312b032e2290630853d
1•kaicianflone•7m ago•0 comments

OpenBSD Copyright Policy

https://www.openbsd.org/policy.html
1•Panino•8m ago•0 comments

OpenClaw Creator: Why 80% of Apps Will Disappear

https://www.youtube.com/watch?v=4uzGDAoNOZc
1•schwentkerr•12m ago•0 comments

What Happens When Technical Debt Vanishes?

https://ieeexplore.ieee.org/document/11316905
1•blenderob•13m ago•0 comments

AI Is Finally Eating Software's Total Market: Here's What's Next

https://vinvashishta.substack.com/p/ai-is-finally-eating-softwares-total
2•gmays•13m ago•0 comments

Computer Science from the Bottom Up

https://www.bottomupcs.com/
2•gurjeet•14m ago•0 comments

Show HN: I built a toy compiler as a young dev

https://vire-lang.web.app
1•xeouz•15m ago•0 comments

You don't need Mac mini to run OpenClaw

https://runclaw.sh
1•rutagandasalim•16m ago•0 comments

Learning to Reason in 13 Parameters

https://arxiv.org/abs/2602.04118
1•nicholascarolan•18m ago•0 comments

Convergent Discovery of Critical Phenomena Mathematics Across Disciplines

https://arxiv.org/abs/2601.22389
1•energyscholar•18m ago•1 comments

Ask HN: Will GPU and RAM prices ever go down?

1•alentred•19m ago•0 comments

From hunger to luxury: The story behind the most expensive rice (2025)

https://www.cnn.com/travel/japan-expensive-rice-kinmemai-premium-intl-hnk-dst
2•mooreds•20m ago•0 comments

Substack makes money from hosting Nazi newsletters

https://www.theguardian.com/media/2026/feb/07/revealed-how-substack-makes-money-from-hosting-nazi...
5•mindracer•21m ago•0 comments

A New Crypto Winter Is Here and Even the Biggest Bulls Aren't Certain Why

https://www.wsj.com/finance/currencies/a-new-crypto-winter-is-here-and-even-the-biggest-bulls-are...
1•thm•21m ago•0 comments

Moltbook was peak AI theater

https://www.technologyreview.com/2026/02/06/1132448/moltbook-was-peak-ai-theater/
1•Brajeshwar•22m ago•0 comments

Why Claude Cowork is a math problem Indian IT can't solve

https://restofworld.org/2026/indian-it-ai-stock-crash-claude-cowork/
2•Brajeshwar•22m ago•0 comments

Show HN: Built an space travel calculator with vanilla JavaScript v2

https://www.cosmicodometer.space/
2•captainnemo729•22m ago•0 comments

Why a 175-Year-Old Glassmaker Is Suddenly an AI Superstar

https://www.wsj.com/tech/corning-fiber-optics-ai-e045ba3b
1•Brajeshwar•22m ago•0 comments

Micro-Front Ends in 2026: Architecture Win or Enterprise Tax?

https://iocombats.com/blogs/micro-frontends-in-2026
2•ghazikhan205•24m ago•1 comments

These White-Collar Workers Actually Made the Switch to a Trade

https://www.wsj.com/lifestyle/careers/white-collar-mid-career-trades-caca4b5f
1•impish9208•25m ago•1 comments

The Wonder Drug That's Plaguing Sports

https://www.nytimes.com/2026/02/02/us/ostarine-olympics-doping.html
1•mooreds•25m ago•0 comments

Show HN: Which chef knife steels are good? Data from 540 Reddit tread

https://new.knife.day/blog/reddit-steel-sentiment-analysis
1•p-s-v•25m ago•0 comments

Federated Credential Management (FedCM)

https://ciamweekly.substack.com/p/federated-credential-management-fedcm
1•mooreds•25m ago•0 comments

Token-to-Credit Conversion: Avoiding Floating-Point Errors in AI Billing Systems

https://app.writtte.com/read/kZ8Kj6R
1•lasgawe•26m ago•1 comments
Open in hackernews

Randomly selecting points inside a triangle

https://www.johndcook.com/blog/2025/09/11/random-inside-triangle/
74•ibobev•4mo ago

Comments

ok123456•4mo ago
If it's the whole triangle, use a Dirichlet RNG with alpha=1.
simlevesque•4mo ago
What's a "whole triangle" ? Google leads me nowhere.
ok123456•4mo ago
meaning each point within the triangle has equal probability
cluckindan•4mo ago
Generate random points inside a square (trivial), mirror one half by the diagonal (preserves distribution), transform coordinates inside the resulting triangle to the given triangle.
mytailorisrich•4mo ago
That's essentially the accept-flip method of the article, isn't it?
cluckindan•4mo ago
Not really. Using a parallelogram means each x-coordinate’s allowed range depends on the y-coordinate and vice versa, but using a square, the coordinates are independent.
emil-lp•4mo ago
You mean inside the resulting rectangle?

That's what the article suggests.

aaronblohowiak•4mo ago
no, this person is not suggesting a parallelogram but rather performing an affine transformation on the triangle to make it a right triangle so they can pick a random point in a square instead. as another commenter mentioned, I believe this distorts the distribution and won't do the right thing.
o11c•4mo ago
There's no distortion for the purposes of randomness (there would be if you cared about distance between specific points before/after the transformation), but the blog article fails to actually explain the method.

Clicking through to SO explains it (but assumes you can read numpy). The `s * u` and `t * v` (where `u` and `v` are vectors) are the transformation from right-triangle (half of square) to triangle (half of parallelgram).

saltcured•4mo ago
Hmm, is this "car(ing) about distance between specific points" something that would matter if we were going to operate in reverse and splat something at each point to render the triangle?

I think that sort of splatting is how I intuitively think about this problem, and likely where I went wrong in thinking there would be a distortion of the density function. I'm not confident whether this actually matters though. Would it still approximate the same distribution regardless of what splat shape is used...?

creata•4mo ago
https://en.wikipedia.org/wiki/Probability_density_function#V...

Affine transformations just scale the probability density by a constant, so a uniform distribution is still uniform.

aaronblohowiak•4mo ago
ah, excellent point. thanks. this works if they are transforming the triangle to be a right triangle to make a rectangle but if they are making it half a square, that could not be accomplished solely with affine transformations (if I figure correctly...)
cluckindan•4mo ago
But you can just map one right triangle to the other without affecting the distribution.
saltcured•4mo ago
Wouldn't that subsequent transform distort the sample distribution? As you make the angle at one vertex more obtuse, the density of the point mapping increases more there relative to the points near the other, more acute vertices.
hatthew•4mo ago
I believe an affine transformation would keep density perfectly consistent across the whole area.
atq2119•4mo ago
Affine transformations don't change relative density.

You can think of it this way. There's a density function on the shapes in question. Whenever you transform the 2d space, you have to adjust the density at the same time to preserve "volume" (area times density).

Non-linear transforms, such as interpreting a square as polar coordinates to obtain a disk, will expand or shrink area differently in different parts of the space, which means that if you start with a uniform density, you end up with a non-uniform density. But linear/affine transforms affect area the same everywhere in the space, and so if the density is uniform to begin with, it remains uniform.

saltcured•4mo ago
Thanks, I should have reminded myself that my intuitions are often non-mathematical. I don't even know how I decided that a change in angle would have a non-linear effect on density.

I also had an intuition that the aspect ratio change would squish the distribution. I guess this aspect ratio doesn't matter for the density distribution of dimensionless points.

But, if doing something like splatting a pixel/sprite at each point coordinate, would the sprite shape need to be transformed to match...?

Etherlord87•4mo ago
Not square, rectangle. The article speaks of a parallelogram but you can the distribution will be the same for the rectangle.
cluckindan•4mo ago
Square works just as well.
hatthew•4mo ago
I doubt I'm more geometrically inclined than the average HN user, but to me the general "accept-flip" method mentioned here seems trivial, obvious, and already solved, to the extent that I'm surprised it's worth writing more about or considering any alternatives.
spankalee•4mo ago
Generating random points uniformly in a circle without rejection is at least mildly more interesting, as you need to scale one factor by a square root:

    const r = sqrt(random()) * radius;
    const theta = random() * TAU;
hatthew•4mo ago
Yeah that would be at least nontrivial, but has been written about so much that the bar for a worthwhile article seems pretty high.
arijun•4mo ago
Wait, wouldn't this result in the opposite of what you want? You want to shift the distribution out, not crowd the center, so you probably want to square your random instead.
hatthew•4mo ago
assuming random() returns values 0<=r<=1, sqrt will shift the distribution outward
Jtsummers•4mo ago
Squaring numbers in (0,1) makes them smaller, pulling the random radius closer to center. As an example consider 0.9. Squaring it gets 0.81 vs 0.949 taking the square root.
arijun•4mo ago
Oh yes all of you are right. In my defense, I am stupid.
hhmc•4mo ago
Because the numbers are less than 1 sqrt pulls them towards 1 (the edge)
hk__2•4mo ago
Obligatory xkcd: https://xkcd.com/1053/
o11c•4mo ago
This appears to be low-quality blogspam. It fails to even explain the main method (delegating to a handwaved "generate in a parallelogram").
hatthew•4mo ago
I didn't want to be that critical right out of the gate, but yeah if an "experienced consultant" thinks that this is worth writing about at this level of detail, then that makes me trust them less, not more.
oakwhiz•4mo ago
A parallelogram is just a rectangle with extra steps. Maybe they could have mentioned what those steps are but it seems fairly straightforward
geophile•4mo ago
[flagged]
mweatherley•4mo ago
A tidbit here some might be interested in is that a version of the accept-flip method works for simplices of arbitrary dimension.

For an n-simplex, start by generating a random point in an n-cube (i.e. n uniform random numbers between 0 and 1).

Next, sort the coordinates. This leaves you with a chain `0 <= c_1 <= ... <= c_n <= 1`.

Taking successive differences from this chain gives you n+1 numbers `d_j` (`0 <= j <= n`) that sum to 1.

Finally, the random point in the n-simplex is just `j_0 v_0 + ... + j_n v_n`, where `v_j` are the vertices of the simplex.

It's not hard to verify that this produces the accept-flip technique in dimension 2. As for why it's uniform: the sorting step is mapping a coordinate in the cube into a fundamental domain for the action of the symmetric group (which breaks the cube into a number of simplices of equal size); the other steps are linear maps, which therefore preserve the uniformity.

Syzygies•4mo ago
I coauthored the paper "Trailing the Dovetail Shuffle to its Lair" which solved the GSR model for riffle shuffling in closed form, leading to the recommendation to shuffle a 52 card deck seven times.

Your picture is a great geometric way to think about riffle shuffling. Your n-simplex represents a sorted deck of n cards. Choosing a point uniformly at random in this simplex makes the needed choices all at once to predetermine an arbitrary number of riffle shuffles. Think of k riffle shuffles as a single 2^k shuffle (as if you had 2^k hands); we can now study an "a-shuffle". Scale the n-simplex by a factor of a. Where does our random point end up? Either view all of space as tiled by your n-cubes, or reduce all coordinates mod 1. Either way the random point ends up in some n-simplex described by a different (or the same) order (mod 1) of the coordinates. That's your shuffle.

For a single shuffle of two cards, doubling the 2-simplex ("up-triangle") covers three up-triangles and one down-triangle, so the odds of reversing the cards is 1 in 4. This makes sense if you imagine two "stowaway" cards face up, placed at random in a face-down deck. Shuffling the deck, to reverse these cards they can't both be in the same packet, and being in different packets only reverses them half the time.

Increasing "a" for two cards, one sees the up and down-triangle counts converge to a 1:1 ratio. The error "fringe" looks like a numerical integration error.

Malipeddi•4mo ago
There are other quite elegent methods for triangle and simplices.

For a triangle, drawing α and β uniform over [0,1) the barycentric coordinates given by (1-sqrt(α), sqrt(alpha)(1-β), βsqrt(alpha)) is uniform over the triangle. No rejection and no test for flipping.

For simplices (triangle, tetrahedron, 5-cell etc) barycentric coordinates obtained by drawing uniformly from (0,1] taking a log and normalizing will be uniform within the simplex.

I wrote about this and other related sampling below.

https://abhila.sh/writing/5/Random_Sampling.html

https://abhila.sh/writing/8/Random_Sampling_2.html

tempfile•4mo ago
Here was a cute idea I thought of. Divide the triangle into 4 by joining the midpoints (a "triforce" shape). The four triangles are congruent, each equal to a quarter of the larger triangle. Generate a uniform 1/4 probability event in your favourite way (flip two coins) and accordingly choose one of the triangles to contain your point. Repeat this indefinitely to get an exponentially small triangle containing your point.

I think this should be a uniform distribution by symmetry. Obviously the boundaries of the triangles never get picked but that's a measure 0 set.

wpollock•4mo ago
I'm certainly not knowledgeable about these algorithms, but I'm willing to look foolish.

In any regular polygon, you can fill it with a line of any thickness by starting at one vertex and spiraling inward until the shape is completely filled. The line can be as thin as required for any application.

The problem is now transformed into finding random points on a finite line. I don't have the mathematical chops to know, but I'd guess that finding the length of such a line and coverting to the 2d coordinates of any point on the line would be possible perhaps even practical. Does anyone here know if this is possible?

teraflop•4mo ago
So from a mathematical perspective, the issue is that your "line" (path) actually has zero thickness, and so there are gaps between the spiral windings. If you sample a point from any finite-length path then you have probability zero of hitting any of the points in the gaps between segments. (Maybe you don't care about this if the gaps are sufficiently small, but from a mathematical perspective it's not strictly valid.)

And you can't just say "the path is infinitely long and spirals infinitely many times" because then you have no way of uniformly sampling a random real number between zero and infinity (it can be proven that no such probability distribution exists).

But I think the basic idea is sound and you make it work by formulating it slightly differently:

1. Divide up the triangle into infinite concentric triangles

2. Choose a random triangle with probability proportional to that triangle's length

3. Choose a random point on that triangle's perimeter

The interesting part is step 2. If you parameterize the triangles by a scale factor s, ranging from 0 to 1, then the perimeter is proportional to s. So I believe you can choose s appropriately by choosing x uniformly at random from 0..1 and letting s = sqrt(x). See https://en.wikipedia.org/wiki/Triangular_distribution

Then step 3 is mathematically straightforward: if the lengths of the triangle's sides are a,b,c, you choose a random number between 0 and a+b+c, and "wrap" that length around the triangle's perimeter. Then you have to do the correct coordinate transformation to find the appropriate point on the scaled triangle you chose.

So I think it would work, but it probably wouldn't be any simpler to implement than the "accept-flip" method described in the article.

Etherlord87•4mo ago
I solved this problem in Blender [1] in the past using python's `random.triangular()` [2], and the name suggests this problem is the best example of when you would need `triangular()` and how its distribution works.

[1] https://blender.stackexchange.com/a/221597/60486 [2] https://docs.python.org/3/library/random.html#random.triangu...

layer8•4mo ago
> Create a parallelogram by attaching a flipped copy of the triangle.

You don’t need to duplicate the triangle. You can also turn any triangle into an equal-area rectangle like this: https://youtu.be/nVz3kCrJLWo?t=77

Bad ASCII art:

           /|\
         / A|B\
       /____|__\
     /      |   \
   /        |    \
 ’——————————+—————`
The middle horizontal line cuts the height of the triangle in half. Rotating the upper two “quarter” triangles A and B by 180° around the end points of the horizontal line completes the lower half to a rectangle:

  ________________
 | A /      |   \B|
 | /        |    \|
 ’——————————+—————`
Depending on the coordinate representation/quantization, one drawback might however be that if a random point lands exactly on one of the edges of A and B, the mapping between the triangle and the rectangle is not a bijection. (For example, the single edge between A and B in the triangle becomes two separate edges in the rectangle. Likewise for the middle horizontal line, and conversely for the diagonal triangle edges.)
fuzzythinker•4mo ago

          ⋰|\  
        ⋰ A|B\  
      ⋰____|__\  
    ⋰      |   \  
  ⋰        |    \  
 ’——————————+—————`  
For shallower slopes, use the 3 dots