Random.. How random it is?

Recently found out great stuff - that you can move the phrases out to their own file. Somehting like below

  - service: tts.yandextts_say
    entity_id: media_player.vannaya, media_player.zal_tts
    data_template:
      message: !include ../sounds/phrases_bathtime.yaml

In than file - standard notation

>
  {{ [
    "phrase1",
    "phrase2",
     "phrase3"
  ]|random }}

With that in mind i have set up a file with over 50 phrases to get called when it’s bath time for my daughter. The problem is - it’s not that random. Actually “phrase 4” gets called out almost every second day… Anybody else is noticing that random behaviour is not that random?

Not to deminish your issue but truely random would mean the chance of getting phrase 4 would be equal every day. 1:50

So having it called out every other day (50%) seems a wrong behavior… or really bad luck :roll_eyes:

That’s not exactly how probability works. The “trend” of it getting called 50% of the time is purely coincidence assuming that there is ample entropy available. For instance, flipping a coin 4 times and getting heads all 4 doesn’t make it any more or less likely that you’d get tails on the fifth time. Unless your a ghost tracking down an old friend that may have been responsible for your death…

I agree that in randomness there is a chance for a sequence with many repetitions of the same item, and for a “physical” event like a coin toss that would be my bet.
But because we are talking about a software implementation, a sequence with repetition can be the hint of a hidden bug. I’m not screaming “buggy generator”, but maybe it would be worth to take a look.

Yep getting 1 specific entry half the time from a collection of 50 entry seems pretty unlikely.
But who knows ^^

Maybe try to manually trigger that automation several time, and see if this entry 4 still comes up most of the time or if it was just randomly picked several time?

Could it have anything to do with this issue:

The include maybe just insert one value? And you only get new value after a restart?