Problem random sampling

Hello everyone.

I've created an app to generate NPC for TTRPG and while it works great, I've noticed that whenever the session ends and I start the app again..... it looks like it's resetting to a specific seed so that the NPC created are basically always the same.

Problem is, I didn't set any seed.

For example :

I've generated an NPC from the published webapp and got "Thokmay - 30 yo, completely bald or shaved with a large bushy mustache".

I closed the browser, waited a bit, opened it again, started the app and when I generated the NPC, exact same result.

I turned off the computer, waited, generated an NPC and still Thokmay.

Just in case, I completely cleared the cache and cookies, turned everything off and yet.... still Thokmay.

I tried it again by generating 3 NPCs at once and in each scenario, the NPCs were the same

What's even weirder is that if I use not the published webapp but directly from Rstudio, I don't have that problem.

The script itself is very simple, I import a dataframe with names and stuff and just :

  name <- list_names %>% 
   filter(Gender==gender) %>% 
    sample_n(1,replace = TRUE) %>% 
    pull(XYZ)
  
  age<- round(rnorm(n=1, mean=45, s=15),0)

Do you guys have any idea what may be causing that ?

Just to be safe, try replacing your sample_n() command with head() and verify that more than one record is selected. If only one record matches the filter criterion, random sampling will not be very random.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.