15,913,140 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by OzWaz (Top 10 by date)
OzWaz
12-Aug-20 19:07pm
View
Thanks
Interesting experience for me.
I effected the changes as advised and uploaded it to my web server.
Strangely enough entering one value (Say 10000) will returns a "Percentage" result to two decimal places, yet entering a subsequent value (Say 11000) will returns a result to 12 decimal places.
It also gives the same result without the change.
You might like to tested it yourself but it is beyond my understanding-any further suggestion?
Regards
OzWaz
12-Aug-20 5:11am
View
Richard
Maybe best to look here http://warrenbolton.com/site/fliper3.php
OzWaz
12-Aug-20 5:02am
View
Probabilities
Enter Number :
';
echo "Of which the following resulted:-";
?>
";
}
}
flipper($tell);
?>
Consecutive Heads No. of times % of Total Tested $i $sets[$i] $per
OzWaz
12-Aug-20 4:59am
View
The program is working fine but I am sorry to report Richard that I think there is a couple of things that php cannot do that my basic program could.
For example, here is print out of my Basic
Number of flips undertaken was: 5000000
Number of 1 consecutive heads was:2498815 @ 49.9763 % of Flips
Number of 2 consecutive heads was:1249607 @ 24.99214 % of Flips AND @ 50.22 % of 1
Number of 3 consecutive heads was:624458 @ 12.48916 % of Flips AND @ 49.85 % of 2
Number of 4 consecutive heads was:311990 @ 6.2398 % of Flips AND @ 51.26 % of 3
As you can see - as well as recording the consecutive data (A) it also calculates and prints the percentage of each particular consecutive relevant to the total (B) PLUS it then calculates and prints the percentage of each particular consecutive relevant to the one immediately prior (C).
I was able to deduce how to modify your program to achieve the achieve B but to achieve C maybe a bridge to far I think
Viz:
Consecutive Heads No. of times % of Total Tested
1 500173 50.0173
2 249894 24.9894
3 124893 12.4893
4 62705 6.2705
5 31249 3.1249
The other deficiency is that it cannot analyse 1,000,000,000 cycles it returns this
“Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\coin\fliper3.php on line 42”
About 75,000,000 cycles is all it will do I have not idea why
I have supplied the program in case you want to take it for run
Regards
OzWaz
11-Aug-20 2:10am
View
Yes, that is correct it is now a PHP program that does exactly the same as small basic does - but with a few limitations.
Firstly, small basic also has an input facility so that you can enter the number of flips from the front end as would do with php and the HTML form tag into a database- But I can work on that one.
Secondly, it’s not correct to say “And crucially, when it goes wrong it is much easier to debug.”
It’s only easier to debug for those who have a good grasp of PHP but for me just starting to learn about PHP and without constructing the program myself and understanding how it all works - it would be a horror, whereas small basic is very easy for me to debug.
But it is a solid base and by analyzing it and playing with it, I am sure that I can deduce what all the functions are and eventually I will be able to use it in the format I want.
I couldn’t stay in small basic because I don’t know how to embed that into a HTML webpage.
I do appreciate that you’ve stayed with me on this project it’s been an interesting journey and again I thank you for all your efforts
OzWaz
9-Aug-20 0:43am
View
Sorry I didn’t actually look at the code in detail, I just copied and pasted it into a file with some HTML header and ran it through my XAMPP system.
Not being that familiar with PHP and now taking a look at the code I see the code was not closed off “?>” - So once I closed it, the error message when away.
Now when I run the code nothing prints to the screen.
If the code was replicating the function of the Small Basic program it would have delivered a printout like this:
Number of flips : 1000
Heads - 1 :488
Heads - 2 :242
Heads - 3 :117
Heads - 4 :59
Heads - 5 :27
Heads - 6 :20
Heads - 7 :7
Heads - 8 :4
Heads - 9 :3
Heads - 10 :1
Heads - 11 :
Heads - 12 :
Heads - 13 :
Heads - 14 :
Heads - 15 :
Heads - 16 :
Heads - 17 :
Heads - 18 :
Heads - 19 :
Heads - 20 :
Heads - 21 :
Heads - 22 :
Heads - 23 :
Heads - 24 :
Heads - 25 :
Heads - 26 :
My Dreamweaver program is telling me that there is a problem with this line of code
“$sets = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];”
However, https://phpcodechecker.com/is telling me that the code is fine.
But none of this really matters because all I am trying to do is to find out why my use of the "goto" in my PHP scrip did not work. I wasn’t actually looking for someone to write the program for me.
In closing I don’t understand what you meant by this
["why the goto function in the initial code that I posted does not work"- I don't think I made that claim.]
and $Vegemite="Yuck";
Regards
OzWaz
7-Aug-20 16:53pm
View
Firstly, Richard I would like you to know I appreciate your efforts, PLUS: People who volunteer to give of their time and abilities to help other people - for no reward, I find are amazing.
However when I posted a portion of code seeking help from the Forum to resolve a conundrum, the outcome I was looking for was to find out why the PHP “goto” facility in my code (as described in the PHP manual https://www.php.net/manual/en/control-structures.goto.php) was not performing as such, in my code.
In my search to resolve the problem before I sought the assistance of this Forum I had already been acquainted with the fact that in the practice of coding in this language, the use of the 'goto' facility in your code was, at worse, frowned upon and at best to be used with caution.
So I was already aware of that particular situation BUT I noted the comment on the above cited webpage “Basically, the fight against 'goto' is just a side effect of a misleading article many decades ago. Those monsters are gone now. Feel free to use it when you know what you're doing.”
Many people are happy to eat food without known how to grow it, unfortunately for me, my personality is not of that ilk.
My objective is to be able to learn enough and understand its function in PHP to be able for me to reproduce the basic program that works- in PHP.
Figuring out how something works so that I can use it with confidence and fix it if it breaks is how I like to do things.
I did out of curiosity also run your code on my XAMPP system but come up with this error:-"Parse error: syntax error, unexpected '<', expecting end of file in C:\xampp\htdocs\coin\fliper.php on line 28"
If you know the reason as to why the goto function in the initial code that I posted does not work, it would be great if you would share that, otherwise thank you for all your efforts but I must look elsewhere.
Regards Warren
OzWaz
4-Aug-20 0:14am
View
Thanks, Richard, for trying to give me assistance with the php code
I don’t see how it can work the same as the Basis code does.
As you can see from the code above (Basic), the program acts like cascading wine glasses assessing consecutive event and aborting progress when an unsupported option is presented.
This together with the counter allows the recording of a large the number of consecutive events for 26 circumstances.
Here is a sample of the data generated
Events 10,000
Selected 5008
Consecutive
2 2474
3 1236
4 672
5 332
6 153
7 77
8 31
9 16
10 6
11 8
12 1
13 0
And so on …
The loop needs to be aborted/redirected each time an unsupported option occurs as a consequence of an event (Random Number generated)
Only approx. 3 times in 1,000,000,000 events does an entire Loop occur.
The reason why “it runs (almost) for ever.” is that as you can see from the Basic Program code above “While flip < num” php equivalent - is missing.
Coding is not a large part of my life and fondly enough I find it more time efficient to copy and paste that to spend time searching for a more efficient alternative.
It actually does the same job and the computer doesn't seem to mind how long you code is.
I did read some of the criticisms of using the “goto” facility but in certain situations, like mine, where my programs are not complex and for no one else’s use but mine they still have a legitimate (and BEST Option) application - if only they (php) would work.
Regards
OzWaz
3-Aug-20 4:04am
View
Thanks Richard for the response however in the particular application for which I use this program I am not sure that your solution would work PLUS I don’t know enough php to make a new system work in php.
This program takes a coin flips it 1,000,000,000 time calculates the number of recurring sequences for each category up to 35 iterations for a single sequence and then calculates the number of sequencing for each category and then the % differentiation between each category and then % of the total events
I can do that because I understands Basic and have been using it since 1982 and now to old now to learn a new way of plucking chickens, I was hoping to easily convert to php so I could embellish the program with HTML
Here is the program if you can tell me how to achieve that in php I would be grateful
program:
TextWindow.ForegroundColor = "Yellow"
TextWindow.Writeline("What amount?")
num = TextWindow.Read()
flip = 1
Start:
While flip < num
flip = flip + 1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
A = A +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
B = B +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
C = C +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
D = D +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
E = E +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
F = F +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
G = G +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
H = H +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
I = I +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
J = J +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
K = K +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
L = L +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
M = M +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
N = N +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
O = O +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
P = P +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
Q = Q +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
R = R +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
S = S +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
T = T +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
U = U +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
V = V +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
W = W +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
X = X +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
Y = Y +1
rn = Math.GetRandomNumber(2)
If rn = 1 Then
goto start
EndIf
Z = Z +1
EndWhile
TextWindow.Writeline("Number of flips undertaken was: " + flip)
TextWindow.Writeline("Number of 1 consecutive heads was:" + A + " @ " + A*100 /flip + " % of Flips")
TextWindow.Writeline("Number of 2 consecutive heads was:" + B + " @ " + B*100 /flip + " % of Flips " + "PLUS @ " + Math.Round(B*100/A) + " % of 1")
TextWindow.Writeline("Number of 3 consecutive heads was:" + C + " @ " + C*100 /flip + " % of Flips " + "PLUS @ " + Math.Round(C*100/B) + " % of 1")
TextWindow.Writeline("Number of 4 consecutive heads was:" + D + " @ " + D*100 /flip + " % of Flips " + "PLUS @ " + Math.Round(D*100/C) + " % of 1")
TextWindow.Writeline("Number of 5 consecut
OzWaz
14-Mar-18 4:04am
View
Thanks for the advice. Was looking for a 'Reply' Button and didnt deduce that the 'Have a Question or Comment' was the approperate pathway - But now I know
Show More