MsWsII PRNG plus Help file
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: MsWsII PRNG plus Help file
MsWsII.bas + "Mysvalues.bi" adds up to about, 340K characters – six posts assuming, 64000 characters per post.
I don't think so.
Another method is to use an online repository for the constants in addition to my server. My web host is one of the best in the UK and I have been using it for years without issue. The likelihood of it going down, and the online repository at the same time, is pretty slim. I will look into that. The FB forum has been known to be inaccessible, but not of late.
The Views are going quite well considering the OP was in the early afternoon but, as usual, precious little feedback. adeyblue's post took more than a few minutes to knock out from reading to writing, but a handful like that should result in a much better Help file. I am looking at the 'practicals' as I write this; authors are not the best people to write Help files. They have to have the ability to assume the mantle of a user – not easy. They tend not to ask "Waht if?" because they know the answer.
I don't think so.
Another method is to use an online repository for the constants in addition to my server. My web host is one of the best in the UK and I have been using it for years without issue. The likelihood of it going down, and the online repository at the same time, is pretty slim. I will look into that. The FB forum has been known to be inaccessible, but not of late.
The Views are going quite well considering the OP was in the early afternoon but, as usual, precious little feedback. adeyblue's post took more than a few minutes to knock out from reading to writing, but a handful like that should result in a much better Help file. I am looking at the 'practicals' as I write this; authors are not the best people to write Help files. They have to have the ability to assume the mantle of a user – not easy. They tend not to ask "Waht if?" because they know the answer.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: MsWsII PRNG plus Help file
to fxm on his hitting 11,000 posts. Astounding.
-
- Posts: 606
- Joined: Nov 28, 2012 1:27
- Location: CA, USA moving to WA, USA
- Contact:
Re: MsWsII PRNG plus Help file
adeyblue:
" ... one place ... "
All here in this forum thread.
I now have it and did not have to hunt anywhere else for it.
If there are changes or clarifications, I trust I can look here for them.
" ... one place ... "
All here in this forum thread.
I now have it and did not have to hunt anywhere else for it.
If there are changes or clarifications, I trust I can look here for them.
Re: MsWsII PRNG plus Help file
"When a horse breaks a leg, it gets shot."deltarho[1859] wrote: ↑Apr 12, 2022 22:33When a horse breaks a leg, it gets shot. As far as I am concerned, 'fbmath.bi' broke a leg as soon as it came out of the stable.fxm wrote:I too often suffer when I read a number of codes on this forum, but I don't say anything so as not to be only critical and not constructive.
This of course mainly only happens in places where people are influenced by any of the three religions derived from the house of David.
But that is another story.
So long as Mysvalues.bi and MsWsII.bas are easily obtained then the help file is easy enough to follow I reckon.
I like to test deltarho's code to destruction rightly or wrongly now and then, and that is the main bit.
To a beginner even the fb runtime rnd could be a bit confusing I would say, with the five options with #4 included (different seeding).
Thank you deltarho[].
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: MsWsII PRNG plus Help file
Rnd( randd ) works in 32-bit mode and 64-bit mode. The bit size of a variable has nothing to do with the mode of operation. Since GetDuo is effectively a Rnd split into two 32-bit outputs, why am I not allowing GetDuo in 32-bit mode? The simple answer is: I don't know. Perhaps I was due a cup of tea and had put it off for too long.
The remedy is simple: Search MsWsII.bas and remove the GetDuo restriction. You will find one in 'Type MsWsParams' and the other in the GetDuo definition.
I have corrected the opening post.
The Help file now needs correcting, but I am working on that as per adeyblue's critique. dodicat says, “the help file is easy enough to follow I reckon.” but I am inclined to agree with adeyblue's “a bit lacking in the practicals”. The taking snapshots description is now much more informative. I have also reordered the topics. I had 'Restoring the initial state' before 'Snapshots'. That is now reversed. 'Restoring the initial state' is a special case of taking snapshots, so we should talk about taking snapshots first. I will have Version 1.1 of the Help file finished in a day or so and, hopefully, meets with adeyblues's approval.
I have considered an online repository in addition to my web server with regard Mysvalues.bi, but have decided against it. Fasthosts in the UK have been my web host for nearly 20 years and outages is not in their vocabulary. Perhaps I could do better nowadays, but if it ain't broke, why fix it. It doesn't cost much. Besides which, if I change my web host all my images, including smilies, and downloads posted here will disappear.
The remedy is simple: Search MsWsII.bas and remove the GetDuo restriction. You will find one in 'Type MsWsParams' and the other in the GetDuo definition.
I have corrected the opening post.
The Help file now needs correcting, but I am working on that as per adeyblue's critique. dodicat says, “the help file is easy enough to follow I reckon.” but I am inclined to agree with adeyblue's “a bit lacking in the practicals”. The taking snapshots description is now much more informative. I have also reordered the topics. I had 'Restoring the initial state' before 'Snapshots'. That is now reversed. 'Restoring the initial state' is a special case of taking snapshots, so we should talk about taking snapshots first. I will have Version 1.1 of the Help file finished in a day or so and, hopefully, meets with adeyblues's approval.
I have considered an online repository in addition to my web server with regard Mysvalues.bi, but have decided against it. Fasthosts in the UK have been my web host for nearly 20 years and outages is not in their vocabulary. Perhaps I could do better nowadays, but if it ain't broke, why fix it. It doesn't cost much. Besides which, if I change my web host all my images, including smilies, and downloads posted here will disappear.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: MsWsII PRNG plus Help file
The opening post now has two links: Mysvalues.zip is a zip of Mysvalues.bi and MsWsII.zip is a zip of the Help file.
The Help file is now at Version 1.1 considering adeyblue's critique.
Many of the code snippets now include what I call 10^9 tests.
For example with GetDuo in 32-bit mode:
In theory we should get 0.5 0.5
With one run I got
0.499997736617551 0.5000090045823177
That accuracy is typical of MsWsII. On the accuracy stakes, MsWsII seems to have a slight edge on other generators looked at. I put that down to an exceptional distribution uniformity.
A bit of a cheek, but if adeyblue casts an eye on the new Help file and reports back, I would appreciate it. I should like to think that I have understood his “a bit lacking in the practicals” comment.
Take a look at the Credits topic.
The Help file is now at Version 1.1 considering adeyblue's critique.
Many of the code snippets now include what I call 10^9 tests.
For example with GetDuo in 32-bit mode:
Code: Select all
? "Average x, y over 10^9
?
Dim As Double totx, toty
Dim As Uint32 i
For i = 1 to 10^9
msws.GetDuo(x,y)
totx += x
toty += y
Next
? totx/10^9;" ";toty/10^9
With one run I got
0.499997736617551 0.5000090045823177
That accuracy is typical of MsWsII. On the accuracy stakes, MsWsII seems to have a slight edge on other generators looked at. I put that down to an exceptional distribution uniformity.
A bit of a cheek, but if adeyblue casts an eye on the new Help file and reports back, I would appreciate it. I should like to think that I have understood his “a bit lacking in the practicals” comment.
Take a look at the Credits topic.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: MsWsII PRNG plus Help file
Dummy post to change title in General forum.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: MsWsII PRNG plus Help file
The opening post was also “a bit lacking in the practicals” so I added 'Getting started:' just before the code section. I imagined a newcomer reading the opening post and thinking, “Now what do I do?”
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: MsWsII PRNG plus Help file
If you have copied MsWsII.bas, I suggest a replacement for the GetDuo procedure.
In the above, we have 'One = Cast(Uint32 Ptr,@dummy)[0]/2^32'.
Admittedly, it is compact, but I find it convoluted. A newcomer may scratch their head with Cast, Ptr, and @ in one statement.
A bit more typing is required with the following but, to my mind, it is easier to understand.
By the time gcc has finished the two methods have the same performance, so we are only talking readability here.
I have edited the opening post.
In the above, we have 'One = Cast(Uint32 Ptr,@dummy)[0]/2^32'.
Admittedly, it is compact, but I find it convoluted. A newcomer may scratch their head with Cast, Ptr, and @ in one statement.
A bit more typing is required with the following but, to my mind, it is easier to understand.
Code: Select all
Private Sub MsWsParams.GetDuo( ByRef One As Double, ByRef Two As Double )
Dim As Uint64 Temp
Union GetUint32
OutPut64 As Uint64
Output32(0 To 1) As Uint32
End Union
Dim As GetUint32 u
Engine2
u.Output64 = Temp Xor This.Seed2
One = u.Output32(0)/2^32
Two = u.OutPut32(1)/2^32
End Sub
By the time gcc has finished the two methods have the same performance, so we are only talking readability here.
I have edited the opening post.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: MsWsII PRNG plus Help file
In the Help file I mention that GetDuo is handy for Monte Carlo work. What I hadn't done was to compare it with using two Rnds (randses). Rnd (randse) uses Engine1 and GetDuo uses Engine2. Engine2, for some reason, was found to be exceptionally fast in 64-bit mode. In 32-bit mode, GetDuo is a little slower than using two Rnds. In 64-bit mode, GetDuo is 90% faster than using two Rnds. Monte Carlo was used to estimate PI and the two methods gave pretty much the same accuracy, but, in 64-bit mode, GetDuo was getting the job done in nearly half the time.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: MsWsII PRNG plus Help file
Ignore the last post. I was doing a bit of tweaking and got some strange results. So, I removed the tweak and was unable to reproduce the above. Timing loops with gcc is very problematic. They have admitted it, and I have yet to come up with a method to make sure loops are not interfered with. There are some methods to help, but they do not work with FreeBASIC. If I cannot prove conclusively that GetDuo is beneficial, then I will remove it
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: MsWsII PRNG plus Help file
Here is a way to test GetDuo. It is a simple Monte Carlo for estimating Pi. gcc cannot interfere with the loop too much because lCount is used outside the loop when the estimate of Pi is executed.
One run gave me this:
2 x Rnd is faster than GetDuo in 32-bit. They are neck and neck in 64-bit.
GetDuo is then not living to expectations either mine or Widynski's.
It could be his Intel Core i7-9700 (Q2'19) is cleverer than my Intel Core i7-3770 (Q2'12). Perhaps your CPU is cleverer than mine, so I will leave GetDuo in MsWsII.
From Widynski's Table 1 we have:
I should like to know how he derived the 'msws64 32' time.
The xoroshiro is xoroshiro128+ which is one of Sebastiano Vigna's older generators. His xoroshiro128** is very much better, randomness quality, and is faster. In fact it is a better 64-bit output generator than MsWsII. However, MsWsII's Rnd (randd) is no slouch, and it is handy to have it in the same package as the 32-bit output generator. Engine2's method of 64-bit output is definitely faster than 2 x Engine1 32-bit output.
If any of you have MsWsII working, then give the Monte Carlo code a test to see how your machine handles GetDuo. The reason I ask is that I have another procedure which splits the 64-bit output, but that is not living to expectations either on my machine, so I have not added it.
Code: Select all
#Include "MsWsII.bas"
Dim As Uint32 n = 10^9, i, lCount
Dim As Double t, x, y, z
lCount = 0
t = Timer
For i = 1 To n
msws.getduo(x,y)
' x = Rnd
' y = Rnd
If Sqr( x*x + y*y) <= 1 Then lCount += 1
Next
Print Timer - t;" seconds"
z = 4*lCount/n
Print "Estimate of Pi:";z
Sleep
One run gave me this:
Code: Select all
32 bit 64 bit
2xRnd 9.217s 3.606s
GetDuo 11.402s 3.602s
GetDuo is then not living to expectations either mine or Widynski's.
It could be his Intel Core i7-9700 (Q2'19) is cleverer than my Intel Core i7-3770 (Q2'12). Perhaps your CPU is cleverer than mine, so I will leave GetDuo in MsWsII.
From Widynski's Table 1 we have:
Code: Select all
Table 1: Time to generate and
sum one billion random numbers
RNG Precision Time
msws64 32 0.87
xoroshiro 53 1.09
msws32 32 1.18
xorwow 32 1.26
msws64 53 1.29
The xoroshiro is xoroshiro128+ which is one of Sebastiano Vigna's older generators. His xoroshiro128** is very much better, randomness quality, and is faster. In fact it is a better 64-bit output generator than MsWsII. However, MsWsII's Rnd (randd) is no slouch, and it is handy to have it in the same package as the 32-bit output generator. Engine2's method of 64-bit output is definitely faster than 2 x Engine1 32-bit output.
If any of you have MsWsII working, then give the Monte Carlo code a test to see how your machine handles GetDuo. The reason I ask is that I have another procedure which splits the 64-bit output, but that is not living to expectations either on my machine, so I have not added it.
Re: MsWsII PRNG plus Help file
My box:
Operating System: Windows 10 Pro 64-bit (10.0, Build 19042) (19041.vb_release.191206-1406)
Language: English (Regional Setting: English)
System Manufacturer: Hewlett-Packard
System Model: HP Compaq 8200 Elite SFF PC
BIOS: Default System BIOS (type: BIOS)
Processor: Intel(R) Core(TM) i5-2320 CPU @ 3.00GHz (4 CPUs), ~3.0GHz
Memory: 8192MB RAM
Available OS Memory: 8080MB RAM
Page File: 3136MB used, 6223MB available
Windows Dir: C:\WINDOWS
DirectX Version: DirectX 12
----------------------------------------------
fb 64 bit (official build 1.09.0)
-O 2 optimisation
using
msws.getduo(x,y)
result:
6.836564900004305 seconds
Estimate of Pi: 3.14158048
using rnd (default)
17.57021140000143 seconds
Estimate of Pi: 3.141638952
Operating System: Windows 10 Pro 64-bit (10.0, Build 19042) (19041.vb_release.191206-1406)
Language: English (Regional Setting: English)
System Manufacturer: Hewlett-Packard
System Model: HP Compaq 8200 Elite SFF PC
BIOS: Default System BIOS (type: BIOS)
Processor: Intel(R) Core(TM) i5-2320 CPU @ 3.00GHz (4 CPUs), ~3.0GHz
Memory: 8192MB RAM
Available OS Memory: 8080MB RAM
Page File: 3136MB used, 6223MB available
Windows Dir: C:\WINDOWS
DirectX Version: DirectX 12
----------------------------------------------
fb 64 bit (official build 1.09.0)
-O 2 optimisation
using
msws.getduo(x,y)
result:
6.836564900004305 seconds
Estimate of Pi: 3.14158048
using rnd (default)
17.57021140000143 seconds
Estimate of Pi: 3.141638952
Last edited by dodicat on Apr 20, 2022 12:18, edited 1 time in total.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: MsWsII PRNG plus Help file
Thanks, dodicat.
What I was particularly interested in was a run as is with msws.getduo(x,y) and then to comment that with a run using x = Rnd and y = Rnd.
Your CPU is Q3'11 so will probably see GetDuo as much a disappointment as with my machine. I am hoping to see GetDuo do better than 2 x Rnd to justify leaving it in MsWsII. Widynski's architecture is only three years old.
What I was particularly interested in was a run as is with msws.getduo(x,y) and then to comment that with a run using x = Rnd and y = Rnd.
Your CPU is Q3'11 so will probably see GetDuo as much a disappointment as with my machine. I am hoping to see GetDuo do better than 2 x Rnd to justify leaving it in MsWsII. Widynski's architecture is only three years old.
Re: MsWsII PRNG plus Help file
my times
Code: Select all
FreeBASIC-1.10.0-win-gcc-11.2
32-bit
msws.getduo(x,y) Rnd msws.randse
6.175255800011854 seconds 4.360144499974808 seconds
Estimate of Pi: 3.141602616 Estimate of Pi: 3.141706156
64-bit
msws.getduo(x,y) Rnd msws.randse
1.991689099988435 seconds 1.985505999997258 seconds
Estimate of Pi: 3.141536204 Estimate of Pi: 3.1415877