TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Scrambling eggs for Spotify with Knuth's Fibonacci hashing

151 点作者 pncnmnp超过 1 年前

14 条评论

bazzargh超过 1 年前
The fibonacci hashing mentioned here looks to be just Kronecker low-discrepancy sequences <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Low-discrepancy_sequence#Additive_recurrence" rel="nofollow noreferrer">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Low-discrepancy_sequence#Addit...</a> which is used for dithering too (see eg <a href="https:&#x2F;&#x2F;extremelearning.com.au&#x2F;unreasonable-effectiveness-of-quasirandom-sequences&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;extremelearning.com.au&#x2F;unreasonable-effectiveness-of...</a>). It&#x27;s quite likely already what Spotify were obliquely referring to. But I think the author missed a trick: tracks by an artist occur close together if your collection is already arranged by artist&#x2F;album. Picking tracks far apart from the globally sorted list is what this sequence will do, and do you don&#x27;t need to do anything at all to split by artist&#x2F;album&#x2F;category etc:<p>1. for the Kth track in a sorted collection of N with seed S in [0,1), pick track number floor(N((K(phi-1)+S)%1)).<p>2. There is no step 2.<p>Since Spotify suggest their algorithm is only a couple of lines, I&#x27;d guess this is what they did.<p>edited to add: the above would get pretty boring because songs would always follow one another in sequence, no matter what the seed was. But since the chance of picking an irrational number at random in a real interval is a near certainty (because rationals are countable and reals are uncountable) you can just pick any new random number as the stepsize in the sequence when you start to shuffle play and it should be good enough; picking in [.25, .75) avoids steps that take you back too close to the same artist.
评论 #38583897 未加载
评论 #38584053 未加载
评论 #38587865 未加载
jorjordandan超过 1 年前
I was a tile installer in a previous life, and occasionally a customer would make the dreaded request to have an accent tile placed &#x27;randomly&#x27; throughout a backsplash. They were never happy with the placement, and clearly had no understanding of randomness. Generally what they actually wanted was &#x27;evenly distributed&#x27;. I remember one particular customer kept changing the accent tiles and moving them until they converged upon a very specific pattern throughout the back splash except for one tile that was out of the pattern, that they kept &#x27;wrong&#x27; out of some ego driven desire to justify their request for randomness.
评论 #38586474 未加载
j4yav超过 1 年前
I have a playlist with 150 hours of music on it and it seems to play the same five or six songs every day, no matter what. I wish I could choose &quot;actually random&quot;, I wouldn&#x27;t mind unexpected clustering.
评论 #38583255 未加载
评论 #38583362 未加载
评论 #38583294 未加载
评论 #38583329 未加载
评论 #38584147 未加载
评论 #38589300 未加载
评论 #38583551 未加载
评论 #38586080 未加载
galdosdi超过 1 年前
This entire HN thread reads like some fiction made up by a free software activist 15 years ago, as a dystopian cautionary tale. It&#x27;s all complaints and speculations about stuff that just worked back then.<p>Back then we had our music locally and we chose our own players, of which there were many and easy to make another one. Actually, hacking on music playback was easy and not uncommon. We had full control of our musical lives.
评论 #38586856 未加载
评论 #38586452 未加载
justsayinginnt超过 1 年前
Shame we can’t choose the type of shuffle, based on your mood&#x2F;what you’re listening too (not to add even more complexity).<p>e.g. For classical music I’d prefer stringing together pieces from the same orchestra&#x2F;composer. But for some contemporary music would like mix the artist&#x2F;album up more.
评论 #38583225 未加载
评论 #38585174 未加载
评论 #38583558 未加载
ruuda超过 1 年前
I was nerd-sniped by shuffling playlists a while back too and came up with this algorithm: <a href="https:&#x2F;&#x2F;ruudvanasseldonk.com&#x2F;2023&#x2F;an-algorithm-for-shuffling-playlists" rel="nofollow noreferrer">https:&#x2F;&#x2F;ruudvanasseldonk.com&#x2F;2023&#x2F;an-algorithm-for-shuffling...</a>. I&#x27;ve been using it since, my experience at this point is that the interleaving — although it does an optimal job of not playing the same artist twice in a row — is maybe a bit too non-random.
jdontillman超过 1 年前
There was a delightful Usenet post way back around 1990, where someone described how they had just purchased a new multi-CD player. They very excitedly filled it up with their collection of Prince CDs, and set it to random shuffle play mode.<p>Great for a while, but then they complained that all the slow songs were bunched together. And perhaps the random shuffle play mode was sampling the songs, deriving the tempo of each, and adjusting the shuffle accordingly.<p>Very funny.<p>---<p>Heh-heh, I independently came up with Fibonacci hashing for color many years ago.<p>My web app was drawing a diagram of N rectangular items, color-coded to tell them apart, with a table listing the details of each below.<p>(Normally I would use EIA standard colors, with a nod to my EE brethren.)<p>But I didn&#x27;t want the colors to bias anything. So you&#x27;d normally try random colors. But random colors can come out weird and some can be close together.<p>So I used a Golden Angle around the hue circle, with a constant brightness and saturation. And sure enough, the generated colors were nicely differentiated.<p>BUT... not as nice as I&#x27;d like. Something was wrong.<p>It turns out that our perception of color is more complex. And when we&#x27;re differentiating between colors, it really, really helps if the colors are familiar, and describable.<p>So simple colors like blue and purple are much easier to differentiate than a new weird blueish color and a new weird purplish color.<p>So my Golden Angle colors were technically superior, but not as good a user experience.
crazygringo超过 1 年前
My <i>biggest</i> desire for Spotify would be the ability to randomize a playlist but <i>give massive priority to your least-listened songs</i>.<p>So if you have a playlist with 10 songs A-J that you&#x27;ve listened to 10 times each. And then you add 10 new songs K-T that you&#x27;ve listened to 1 time each... Then <i>every time</i> I shuffle the playlist, I want songs K-T to be the <i>first 10 songs in random order</i> until I&#x27;ve played <i>them</i> 10 times each.<p>I mean, things can be mixed up a little more than that... but generally speaking, I want to listen to my least-listened songs much more than the ones I&#x27;ve been listening to forever. But I don&#x27;t want to have to separate them out into special playlists &quot;newest&quot;, &quot;newer&quot;, &quot;kinda new&quot;, &quot;old&quot;, &quot;oldest&quot; which is annoying.
world2vec超过 1 年前
Slightly unrelated but just learned about Hacker News pool. Very interesting.
fetzu超过 1 年前
Spotify’s shuffling is so god-tier bad that I would be flabbergasted if it wasn’t biased towards songs with less royalties to pay out..
2143超过 1 年前
I&#x27;m convinced something&#x27;s wrong with Spotify&#x27;s randomization.<p>When I press the big green play button in a playlist&#x27;s page, it tends to start playing from a specific song, in a weirdly familiar order. So I manually pick a song at random and let it play from there.<p>But even so, some songs almost never get played, but others get played fairly frequently.
darepublic超过 1 年前
I wouldn&#x27;t mind the same artist a couple of times in a row. It&#x27;s what I would arrange for myself, just that the mood of the song being consistent with the theme is important
brcmthrowaway超过 1 年前
What did the ipod shuffle use?
评论 #38586796 未加载
bean-weevil超过 1 年前
I wish they had a setting to go back to the Fischer-Yates shuffle.