C
C#â€¢2mo ago
Angius

# Random temperature curve generation too biased

I'm trying to create a system for a game that would randomize temperature. Not fully randomly, though, I need a more natural curve. So, my idea: introduce a bias that would change towards zero, the faster the more the current temperature diverges from zero. That zero could later be replaced with any desired temperature. Unfortunately, most of the charts I could generate come out horribly biased. Sometimes they're in range -80 to 0, sometimes -10 to 100, very rarely (about 15% chances) are they more sane in a - 20 to 30 range, for example. Here's the source code and my most recently generated charts: https://github.com/Atulin/TemperatureSimulation
9 Replies
Angiusâ€¢2mo ago
Or do I just generate a sine wave and call it a day? :KEKW:
mgâ€¢2mo ago
You could generate a few sine waves at different frequencies and amplitudes and then add them together with random weights
mgâ€¢2mo ago
mgâ€¢2mo ago
I guess the amplitudes would be the weights But yeah, take a sum of sine waves with random frequencies, amplitudes, and phases
Angiusâ€¢2mo ago
That's a good idea, yeah! I could also introduce some daily bias in the [-1, 1] range to make it even more random Wouldn't want the same exact temperature to repeat every x hours
mgâ€¢2mo ago
Yeah, generate new random values every so often so it's not periodic Or just use so many different frequencies that the period is too large to notice
Alexâ€¢2mo ago
Have you tried Perlin Noise? It is often used in game development to achieve smooth pseudo-random number change
Angiusâ€¢2mo ago
Isn't Perlin tileable? Or is it just that the edges of the tiles are the same, but the insides vary per tile Huh, maybe it's a different one I'm thinking of
Alexâ€¢2mo ago
No idea, I just heard that you can use it to get random numbers in unity, but you can try it ðŸ˜€