TIL (about the Dark Arts of HTML)
-
-
@Zecc said in TIL (about the Dark Arts of HTML):
Have you met
@sockpuppet7@fbmac ?
-
@Zecc No, but judging from his avatar I'd rather not. Although there are stairs everywhere I live and work, so I would probably be safe.
No, I haven't whoosh'ed on your joke, I just chose to ignore it and make a different one.
-
@sockpuppet7 said in TIL (about the Dark Arts of HTML):
Rule of 30
At first I thought it's going to be about some new feature in C++20 that would explode the number of automatic methods you need to explicitly override in each and every class you write for your program to behave correctly.
-
@dkf said in TIL (about the Dark Arts of HTML):
@kazitor Is there a modifier to let you choose which eyebrow is raised?
Serious answer: you could try using the Emoji Glyph Facing Direction modifier to flip it one way or the other, though it is likely that this one does not support it.
-
TIL about tittles.
-
-
-
Apparently lizards do pushups as a display of strength and territory, even when there aren't other lizards around.
It might also be to indicate to a predator that they know and won't be surprised.
-
@kazitor this is made manifest in "humans" as well. See the specimens that can't seem to stop flexing.
-
@Tsaukpaetra When lizards do it, it's so fast and looks so effortless that it doesn't give me the impression of requiring much strength at all.
But then I'm not a lizard. Who knows how much they're working out when nobody's looking.
-
@kazitor said in TIL (about the Dark Arts of HTML):
But then I'm not a lizard.
TIL that dragons aren't lizards.
-
@dkf said in TIL (about the Dark Arts of HTML):
dragons
It's more of a rhamphorhynchus (well, rhamphorhynchoidea/non-pterodactyloid), but that plays a part too. Really there's not enough detail to make a proper judgement, though I guess I wouldn't expect pycnofibres to be bright green.
-
Mind = blown
-
@brie said in TIL (about the Dark Arts of HTML):
Mind = blown
People were born in a given year? Why is this surprising?
-
@Tsaukpaetra Right, but those people?
-
@brie Why is that combination of people significant? Everyone who's ever lived had to be born sometime…
-
Famous People Born In 1889
-
I, uh…
[Resiniferatoxin] has also previously been investigated as a treatment for […] premature ejaculation (PE).
-
@dkf When you think of those people, you typically think of them as being from very different parts of history... not as contemporaries. At least, that was true when I thought of them.
-
TIL that while the sequence of numbers generated by
std::mt19937
is, in essence, specified by the standard and therefore must be the same on all systems (when using the same seed, of course), the generation of random numbers on a given distribution using e.g.std::uniform_int_distribution
orstd::uniform_real_distribution
is not, and the sequence that those ones produce can be implementation-dependent (and likely are, since I do get slightly different results between Windows and Linux).Which bothers me to no end since I want full reproducibility of my results and now I can't ensure it across platforms unless I roll out my own generator, which is something I want to avoid at all costs given how easy it is to fuck it up.
-
@kazitor said in TIL (about the Dark Arts of HTML):
I, uh…
[Resiniferatoxin] has also previously been investigated as a treatment for […] premature ejaculation (PE).
After reading TFA: paging @anotherusername ...
-
@remi said in TIL (about the Dark Arts of HTML):
Which bothers me to no end since I want full reproducibility of my results
Don't use a random number generator if you want consistent results?
-
@Tsaukpaetra Wouldn't be a stochastic method without it.
The reproducibility isn't really required from a theoretical point of view, but in practice it's impossible to debug and correctly analyse results if you can't reproduce them.
I'll probably live with the reproducibility being limited to each platform, although of course as soon as I say that Murphy is going to rear its ugly head and I'll get a weird bug on one platform and not the other and won't be able to isolate it properly because of that...
-
@remi said in TIL (about the Dark Arts of HTML):
in practice it's impossible to debug and correctly analyse results if you can't reproduce them.
Then splat an array of hardcoded random values for the test.
-
@remi said in TIL (about the Dark Arts of HTML):
TIL that while the sequence of numbers generated by
std::mt19937
is, in essence, specified by the standard and therefore must be the same on all systems (when using the same seed, of course), the generation of random numbers on a given distribution using e.g.std::uniform_int_distribution
orstd::uniform_real_distribution
is not, and the sequence that those ones produce can be implementation-dependent (and likely are, since I do get slightly different results between Windows and Linux).Things that aren't explicitly guaranteed by anyone to never change are not guaranteed to never change. No shit.
Which bothers me to no end since I want full reproducibility of my results and now I can't ensure it across platforms unless I roll out my own generator, which is something I want to avoid at all costs given how easy it is to fuck it up.
Find a library that guarantees stable results and use it. There's no other way.
-
@Gąska said in TIL (about the Dark Arts of HTML):
@remi said in TIL (about the Dark Arts of HTML):
Find a library that guarantees stable results and use it. There's no other way.That's the thing, I was (perhaps naively, I admit) hoping that the standard library would be the one for that. After all, it's supposed to be, well, standard.
I'm not really surprised it works this way (and I understand why it does), but it's still somewhat disappointing.
Also, if you have a good suggestion for that library to use instead, I'm listening (C++, Windows/Linux, license that is compatible with use in a commercial software i.e. no GPL).
-
@Tsaukpaetra said in TIL (about the Dark Arts of HTML):
@remi said in TIL (about the Dark Arts of HTML):
in practice it's impossible to debug and correctly analyse results if you can't reproduce them.
Then splat an array of hardcoded random values for the test.
That could potentially miss bugs that only happen on certain sequences. Using a different random sequence (maybe in addition to a hardcoded "random" sequence) each time you test it would be like "fuzzing" it, and that can also be useful. Just make sure to log the random values so that you can replay them if you do run into some bizarre edge case.
-
@remi said in TIL (about the Dark Arts of HTML):
@Gąska said in TIL (about the Dark Arts of HTML):
@remi said in TIL (about the Dark Arts of HTML):
Find a library that guarantees stable results and use it. There's no other way.That's the thing, I was (perhaps naively, I admit) hoping that the standard library would be the one for that. After all, it's supposed to be, well, standard.
The one thing that's guaranteed about standard library is that every platform has a different implementation that behaves differently in literally every possible way except in cases explicitly listed in the standard document as standard behavior (and often not even that).
I heard Visual C++ compiler didn't have fully working templates until 2005.
-
@brie Obviously, one needs a unit test on each and every possible sequence.
-
This post is deleted!
-
@Tsaukpaetra said in TIL (about the Dark Arts of HTML):
@remi said in TIL (about the Dark Arts of HTML):
in practice it's impossible to debug and correctly analyse results if you can't reproduce them.
Then splat an array of hardcoded random values for the test.
Answer 1: tests? what are those?
Answer 2: there is more than just (non existing) tests. In a complex stochastic scientific algorithm, random-but-reproducible numbers are really needed if one wants to keep a shred of sanity.
-
@mott555 yes... if time permits, of course.
-
@remi said in TIL (about the Dark Arts of HTML):
if one wants to keep a shred of sanity.
I didn't think that was a requirement...
-
@Gąska said in TIL (about the Dark Arts of HTML):
@remi said in TIL (about the Dark Arts of HTML):
@Gąska said in TIL (about the Dark Arts of HTML):
@remi said in TIL (about the Dark Arts of HTML):
Find a library that guarantees stable results and use it. There's no other way.That's the thing, I was (perhaps naively, I admit) hoping that the standard library would be the one for that. After all, it's supposed to be, well, standard.
The one thing that's guaranteed about standard library is that every platform has a different implementation that behaves differently in literally every possible way except in cases explicitly listed in the standard document as standard behavior (and often not even that).
I know, and knowing that I did check that mt19937 was behaving the same way (i.e. was specified in the standard). I did not think it further through and assumed that it would therefore be the same for the rest of the random number things. Obviously I was wrong, and in hindsight I could have suspected it from start, but, hindsight, ...
-
@remi The Microsoft docs suggest that
uniform_int_distribution
ought to be able to be seeded with themt19937
engine, which should give you consistent results.Nice onebox.
#include <random> #include <iostream> using namespace std; int main() { random_device rd; // non-deterministic generator mt19937 gen(rd()); // to seed mersenne twister. uniform_int_distribution<> dist(1,6); // distribute results between 1 and 6 inclusive. for (int i = 0; i < 5; ++i) { cout << dist(gen) << " "; // pass the generator to the distribution. } cout << endl; }
Replacing
rd()
with a constant seed should give you the same sequence each time it's run.
-
@brie No, that's exactly what I'm doing and where I don't get reproducible results on different platforms. On a single one, yes, it works perfectly well, but not when running the same code, same data, same seed (to mt19937), on different systems.
See this SO questions that summarizes it nicely:
And I could swear I read a longer discussion about it with some comments from a MSVC developer explaining why it was complicated but I can't find it in my history, it might have been on a different device (I think it was on reddit?).
-
@remi said in TIL (about the Dark Arts of HTML):
@Gąska said in TIL (about the Dark Arts of HTML):
@remi said in TIL (about the Dark Arts of HTML):
@Gąska said in TIL (about the Dark Arts of HTML):
@remi said in TIL (about the Dark Arts of HTML):
Find a library that guarantees stable results and use it. There's no other way.That's the thing, I was (perhaps naively, I admit) hoping that the standard library would be the one for that. After all, it's supposed to be, well, standard.
The one thing that's guaranteed about standard library is that every platform has a different implementation that behaves differently in literally every possible way except in cases explicitly listed in the standard document as standard behavior (and often not even that).
I know, and knowing that I did check that mt19937 was behaving the same way (i.e. was specified in the standard).
Well, "mt19937" is the name of a specific algorithm with specific configuration variables. Unlike, say, "uniform_int_distribution".
-
@remi ...oh.
Could you just skip the distribution function and get raw data from mt19937 directly?
-
@remi said in TIL (about the Dark Arts of HTML):
I don't get reproducible results on different platforms.
Use this then
-
@TimeBandit said in TIL (about the Dark Arts of HTML):
@remi said in TIL (about the Dark Arts of HTML):
I don't get reproducible results on different platforms.
Use this then
That's what I said!
-
@brie said in TIL (about the Dark Arts of HTML):
Could you just skip the distribution function and get raw data from mt19937 directly?
Or write your own distribution function for the purposes of testing the rest of the code.
Or rather look one up; the literature is quite extensive but knowing what you want it for makes life much easier. Simulations need good spectral properties as they usually use a lot of random values, but nothing so extremely good as crypto (which needs to resist attack by an intelligent adversary).
-
@brie said in TIL (about the Dark Arts of HTML):
@remi ...oh.
Could you just skip the distribution function and get raw data from mt19937 directly?
I could, but then what I really need is a random number on a specific distribution, so at one point I have to have a distribution function, whether I write it myself or use an existing one.
The problem is that writing a good function to get a proper distribution is harder that it looks. I mean, if there was a single easy way to do that, it's unlikely different systems would have different implementations -- or the standard could easily have specified a particular implementation (maybe just as a reference example one). The biggest issue with rolling out my own is that errors in there are very subtle and very hard to detect (like the typical error when rounding a random integer between 0 and N where you end up with 0 or N having a slightly higher or lower probability than other values). That might sound a tiny detail, and it is when you're just using a random value to pick, say, a random colour for a new user avatar, but I have an actual case where that effect (or one similar to it) was actually causing a significant bias in statistics computed over a data set.
@dkf said in TIL (about the Dark Arts of HTML):
Or rather look one up; the literature is quite extensive but knowing what you want it for makes life much easier. Simulations need good spectral properties as they usually use a lot of random values, but nothing so extremely good as crypto (which needs to resist attack by an intelligent adversary).
I could, and in the end I might do that, especially since I can actually lift code of another program that we have and that has its own distribution code. I don't trust that code entirely and I thought it was easier, nicer, more robust, better in every way to use something standard on which people smarter than me spent a lot of time and thought. For now, I'll probably keep using the standard distributions, with a comment somewhere about the (non) reproducibility, and it's likely to be enough for the time being.
It's not life-shattering, but still, I was annoyed that it wasn't as standard as it sounded.
-
@remi said in TIL (about the Dark Arts of HTML):
I was annoyed that it wasn't as standard as it sounded.
You'll get used to that.
-
@remi said in TIL (about the Dark Arts of HTML):
I thought it was easier, nicer, more robust, better in every way to use something standard on which people smarter than me spent a lot of time and thought.
:ohwaityourserious.mpg:
My experience is that the people who want repeatable high-quality random numbers write their own PRNGs. And the only reason you need them is so that you can compare results for the rest of the program between platforms, so in fact the implementation doesn't need to be great; it can be a special testing mode. Once everything else works, switch to the system PRNG and assume that that's working well.
Repetition for testing isn't the same as running in production. This is a case where this vital difference comes to the fore.
-
@dkf Reproducible cross-platform PRNG is nice for some games. See Spacechem's community leaderboards having to label times as Linux/old Mac or Windows/new Mac when random order matters due to the PRNG not being consistent between platforms.
-
TIL https://en.wikipedia.org/wiki/Eternal_September
Let me save you a click:
Eternal September or the September that never ended is Usenet slang for a period beginning in September 1993, the month that Internet service provider America Online (AOL) began offering Usenet access to its many users, overwhelming the existing culture for online forums.
Before then, Usenet was largely restricted to colleges and universities. Every September, a large number of incoming freshmen would acquire access to Usenet for the first time, taking time to become accustomed to Usenet's standards of conduct and "netiquette". After a month or so, these new users would either learn to comply with the networks' social norms or tire of using the service.
-
@Zecc I remember that period. It was hell, as suddenly a vast number of idiots turned up who didn't care about fitting in. It's like being in a nice quiet bar when suddenly 200 sports fans come in and start shouting for Bud Lite.
-
@remi said in TIL (about the Dark Arts of HTML):
I could, and in the end I might do that, especially since I can actually lift code of another program that we have and that has its own distribution code. I don't trust that code entirely and I thought it was easier, nicer, more robust, better in every way to use something standard on which people smarter than me spent a lot of time and thought. For now, I'll probably keep using the standard distributions, with a comment somewhere about the (non) reproducibility, and it's likely to be enough for the time being.
Grab the source of libc++ and extract the functions for
uniform_int_distribution
etc. Then you've got an implementation of the standard function and consistency on all platforms.
-
@topspin and tons of magic code with hidden dependencies and shitload of non-standard compiler pragmas in your project.