frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

I Solved a 7-Day Calculation Problem in a Weekend

https://medium.com/@jithinsankar.nk/how-i-solved-a-7-day-calculation-problem-in-a-weekend-3fb1a54f2518
18•alomaki•3d ago

Comments

alomaki•3d ago
I had a 7-day compute problem, 3 days to solve it, and no extra hardware. Here's what worked.
judahmeek•3d ago
It's odd that OP didn't seem to consider applying the nearest cached value for any given slider stop.

The Gaussian frequency was a cool idea, however.

Also, I would speculate that projected sales would likely be a continuous function in most cases, so I'm curious why they didn't try fitting a function based on initial results.

alomaki•3d ago
OP here,

Ah, good point. To be honest, interpolation didn't even cross my mind.

The model output wasn't just one number, it was a messy JSON with a 12-week forecast. Trying to average two of those felt like a whole other task, and with the deadline, my brain was just stuck on how to pick the right numbers to cache.

But yeah, it's a really great idea. Will definitely keep it in mind for the next demo.

ViscountPenguin•3h ago
Tbh, I'm really not sure why something like this should take 15 seconds to compute. That's roughly a few trillion floating point ops for a problem that has been solvable for decades. I have trouble imagining any reasonable model for mapping price -> sales needing that much compute.

Also, fwiw, I really wouldn't expect clients slider clicks to follow a normal distribution. A normal distribution occurs when you have the sum of a large number of random variables with Finite (and bounded) expectation and variance; or alternatively, when you're modelling a process with known Expectation and Variance, but not any higher order moments. If anything, I'd expect human beings to play with the slider more around extremal points, like the start and end.

jasonjmcghee•1h ago
Also very curious about what kind of model this is and how it could (so far as it sounds) take 100% of the hardware for 15 seconds per request.
mylesp•1h ago
My first instinct would be to do a one or two in the middle then both of the extremes. The assumption that it would be a normal distribution is so strange to me in this situation.
curtisf•3h ago
What is the actual model that takes 15 seconds to compute?

If I understand the setting, you are estimating the demand curve for a given price... And there are only 40 such curves to compute.

Surely each curve is fit with only a few parameters, probably fewer than five. (I think for small price ranges the demand curve is usually approximated as something trivial like y=mx+b or y=a/(x+b)+c)

Why does evaluating the model at a particular price need to take milliseconds, yet alone 15 seconds?

kookamamie•1h ago
This is the right question. The article reads like answering a XY-problem, where instead focusing on the actual issue, the author triples down on polishing a turd.
conductr•2h ago
I have this problem all the time and I can usually run the calcs in a simple multithreaded process pool/queues. While each calc may still take 15s, I run a dozen or more at a time. This helps me refresh the cache in a reasonable amount of time, doesn’t really focus on improving calc speed of the underlying service which is obviously another potential opportunity
ch33zer•2h ago
So parallel precomputation wasn't an option?
sebmaynard•1h ago
Unless I'm misunderstanding, seems like the approach taken here (normal distribution and Monte Carlo simulation) might achieve similar?

https://filiph.github.io/unsure/

stephenbez•1h ago
I would have just had the slider move in increments of $0.10 or $0.05.

If I was a user, I might be confused why the increment is not consistent across the whole range.

Sophira•1h ago
Maybe I'm just confused, but why even use an ML model for this? It's all just calc, right?
thom•1h ago
This is one of those junior engineer moments where they technically did perceive a problem and solve it, but you wish they had just come and asked for some advice first.
haneul•1h ago
Don’t dangle the man - enrich him with your advice!
mylesp•1h ago
This whole article reads like it was written by someone with no ability to step back for a second and think of other much easier solutions. They just go all in on the first thing they think of even when it is not effective at all.

Just increase the increment size, or if you really want 1c increments you could precompute every 5c or so and then just do linear interpolation between them.

EGreg•44m ago
Yeah dude, seriously…

Linear interpolation on small intervals is like, a model of a model. And that’s exactly what differentiable functions are, anyway. And if you want to be fancier then sample the model and fit some polynomials to interpolate between those samples.

If they were really time constrained they could precompute things sparsely first (for a demo the next day) and then progressively refine the values in between.

Why did this trend on HN?

goloroden•1h ago
I „solved” it by ignoring a part of the problem?

Please don’t take this personal, but IMHO that’s not solving the problem. That’s coming up with a workaround.

_dain_•59m ago
It's cool that you got it working in time for the demo, but I think your reasoning is unsound.

>I remembered this from my engineering days at the College of Engineering, Trivandrum. It’s called the Normal Distribution, or Gaussian distribution. It’s based on the idea that data near the mean (the average) is more frequent than data far from the mean.

There are a lot of non-normal distributions where that's the case. The normal distribution is a specific thing that arises from summing together lots of small random variables.

It's not a good model of people moving sliders on a UI: a person's decision to set the value to e.g. 0.8 is really one discrete thing, not a sum of a bunch of independent micro-decisions. There's no physical/statistical law preventing someone from grabbing the slider and thrusting all the way to the left or the right, and in fact people do this all the time on UIs. The client can move the slider however he pleases ...

So I think you just got lucky that the client didn't do that. Don't rely on it not happening in the future!

(You could also imagine fitting a normal distribution to user behaviour, but it turns out the standard deviation is just really large. That would be technically defensible but also useless for your situation, since there would be substantial probability at the min/max values of the finite range. It would be close to uniform.)

(Also, who's to say the mean is in the middle of the slider range?)

Anyway I'm curious what the ML model was doing that took 15 seconds. Are you sure there's no way to speed it up?

Solving LinkedIn Queens Using Haskell

https://imiron.io/post/linkedin-queens/
5•agnishom•25m ago•0 comments

Vera C. Rubin Observatory first images

https://rubinobservatory.org/news/rubin-first-look/cosmic-treasure-chest
431•phsilva•16h ago•91 comments

Tell HN: Meta developer account suspended

25•ArthurVL1•1h ago•0 comments

Backyard Coffee and Jazz in Kyoto

https://thedeletedscenes.substack.com/p/backyard-coffee-and-jazz-in-kyoto
492•wyclif•17h ago•216 comments

Touring the Zig-EM code-scape (2024)

https://zigem.openem.org/post-003/
8•jstrieb•3d ago•2 comments

Fairphone 6 is switching to a new design that's even more sustainable

https://www.androidcentral.com/phones/fairphone-6-official-render-leaks-showcase-its-sustainable-design
246•Bluestein•16h ago•269 comments

How I use my terminal

https://jyn.dev/how-i-use-my-terminal/
390•todsacerdoti•16h ago•187 comments

Is Mathematics Mostly Chaos or Mostly Order?

https://www.quantamagazine.org/is-mathematics-mostly-chaos-or-mostly-order-20250620/
54•baruchel•3d ago•10 comments

The FPGA turns 40

https://www.adiuvoengineering.com/post/the-fpga-turns-40
98•voxadam•3d ago•50 comments

Can your terminal do emojis? How big?

https://dgl.cx/2025/06/can-your-terminal-do-emojis
78•dgl•5h ago•56 comments

Excalidraw+ Is Now SoC 2 Certified

https://plus.excalidraw.com/blog/excalidraw-soc2
163•gmays•6h ago•53 comments

'Dragon prince' dinosaur discovery 'rewrites' T.rex family tree

https://www.bbc.com/news/articles/cy8dzv3vp5jo
50•gmays•3d ago•7 comments

A Deep Dive into Solid Queue for Ruby on Rails

https://blog.appsignal.com/2025/06/18/a-deep-dive-into-solid-queue-for-ruby-on-rails.html
103•fbuilesv•3d ago•41 comments

QuEra Quantum System Leverages Neutral Atoms to Compute

https://www.nextplatform.com/2025/06/20/quera-quantum-system-leverages-neutral-atoms-to-compute/
13•rbanffy•3d ago•0 comments

Show HN: Comparator - I built a free, open-source app to compare job offers

https://comparator-one.vercel.app/
35•MediumD•7h ago•25 comments

Marble Blast

https://marbleblast.vaniverse.io/
61•sunday_serif•7h ago•14 comments

Making TRAMP faster

https://coredumped.dev/2025/06/18/making-tramp-go-brrrr./
187•celeritascelery•17h ago•93 comments

Harvard hired researcher to uncover slavery ties, fires him for finding slaves

https://www.theguardian.com/news/2025/jun/21/harvard-slavery-decendants-of-the-enslaved
43•ryan_j_naughton•2h ago•18 comments

The Tandy Corporation, Part 1 – By Bradford Morgan White

https://www.abortretry.fail/p/the-tandy-corporation-part-1
6•rbanffy•2d ago•0 comments

Resurrecting flip phone typing as a Linux driver

https://github.com/FoxMoss/libt9
93•foxmoss•12h ago•59 comments

Developing a Retro-Roguelike Game for Multiple Platforms in C

https://retrogamecoders.com/roguelike-multiplatform/
28•ingve•2d ago•3 comments

2025 Iberia Blackout Report [pdf]

https://media.licdn.com/dms/document/media/v2/D4D1FAQGcyyYYrelkNg/feedshare-document-pdf-analyzed/B4DZeBtlohGsAk-/0/1750227910090?e=1750896000&v=beta&t=uEftse3BPsTjdLQ3DmjoVkadhUGqf7-MfYj_6UnSS28
168•leymed•13h ago•111 comments

First methane-powered sea spiders found crawling on the ocean floor

https://www.cnn.com/2025/06/17/science/spiders-deep-sea-methane-new-species
107•bookofjoe•2d ago•52 comments

I ported pigz from Unix to Windows

https://blog.kowalczyk.info/article/4/how-i-ported-pigz-from-unix-to-windows.html
70•speckx•3d ago•24 comments

Ocarina of Time Randomizer

https://ootrandomizer.com/
141•nickswalker•3d ago•45 comments

Rocknix is an immutable Linux distribution for handheld gaming devices

https://rocknix.org/
148•PaulHoule•3d ago•50 comments

Launch HN: Reducto Studio (YC W24) – Build accurate document pipelines, fast

73•adit_a•16h ago•48 comments

uv: An extremely fast Python package and project manager, written in Rust

https://github.com/astral-sh/uv
632•chirau•15h ago•276 comments

Minimal Boolean Formulas (2011)

https://research.swtch.com/boolean
95•mcyc•3d ago•18 comments

Breakthrough cancer test predicts whether chemotherapy will work

https://www.telegraph.co.uk/news/2025/06/23/cancer-test-predicts-whether-chemotherapy-will-work/
49•bdev12345•5h ago•13 comments