C
C#•9mo 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
No description
9 Replies
Angius
AngiusOP•9mo ago
Or do I just generate a sine wave and call it a day? :KEKW:
mg
mg•9mo ago
You could generate a few sine waves at different frequencies and amplitudes and then add them together with random weights
mg
mg•9mo ago
mg
mg•9mo ago
I guess the amplitudes would be the weights But yeah, take a sum of sine waves with random frequencies, amplitudes, and phases
Angius
AngiusOP•9mo 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
mg•9mo 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
Alex•9mo ago
Have you tried Perlin Noise? It is often used in game development to achieve smooth pseudo-random number change
Angius
AngiusOP•8mo 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
Alex•8mo ago
No idea, I just heard that you can use it to get random numbers in unity, but you can try it 😀
Want results from more Discord servers?
Add your server