Comments (9)
Sure, I'll take a look. In the mean time, you can also try the platform rng to rule in/out the generator itself - https://modules.ceylon-lang.org/repo/1/com/vasileff/ceylon/random/api/0.0.5/module-doc/api/index.html#platformRandom
from ceylon-random.
Ah, that's pretty cool... I will try it!
from ceylon-random.
@renatoathaydes the statistical tests still pass, and I'm not seeing any significant issues. Where exactly are you seeing the duplicates? Given that with the default values, generateStrings
varies the output length uniformly from 0 to 99 characters, I would expect duplicates for short strings to happen fairly often.
Without doing any math, the output for
for (i in 0:100) {
print(frequencies(generateStrings()).filter((entry) => entry.item > 1));
}
looks reasonable to me, with a fairly common occurrence of multiple 0-length strings.
And this also looks reasonable, with several one and two length duplicates:
for (i in 0:10k) {
value nonEmptyStrings
= frequencies(generateStrings())
.filter((entry) => entry.item > 1)
.map(Entry.key).filter(not("".equals));
if (!nonEmptyStrings.empty) {
print(nonEmptyStrings);
}
}
from ceylon-random.
With the platform-specific Random, the test passes every time.
Because the length is also randomly chosen, it shouldn't happen often that you get two Strings of similar length.
This may be the problem but I find it strange that the other 2 implementations of Random I tried always succeed.
from ceylon-random.
Yes, that is strange for the implementation to matter. But you'll have to let me what sort of call to generateStrings()
is causing problems for me to take a close look.
As for the length, you will almost always get strings of the same length for 100 samples of 100 random lengths.
from ceylon-random.
BTW, if the problem you are seeing is duplicate results for consecutive calls to generateStrings()
, especially on JS, the fix is to create an LCGRandom()
in the calling function, and use the same one for each call to generateStrings()
.
The reason for this is that the seed is based on millis + nanos, which isn't always a great source of unique numbers on JS.
from ceylon-random.
You just found the problem, I believe :)
Anyway, what I had said about length, is that you need both length and contents to be the same to get a duplicate, which is really unlikely, I would think... but of course, there will be Strings with the same length...
from ceylon-random.
I mentioned your library in the docs of https://github.com/renatoathaydes/specks
as I use it to create random test input.
Thanks!
from ceylon-random.
both length and contents to be the same
yes, but for zero-length strings, the contents will always be the same
I mentioned your library
thanks, and congrats on the release!
from ceylon-random.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ceylon-random.