Last active
September 20, 2019 07:29
-
-
Save dietercastel/9b86d0633b30c69b2d666a9e9f82799b to your computer and use it in GitHub Desktop.
Plotting on a logaritmic scale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Plot of calculating the win chance for g-player Rock, Paper, Scissors. | |
# A winning RPS game contains exactly two options. | |
#Total amount of options BigInt function | |
tot(g) = 3^BigInt(g) | |
#Winning options BigInt function | |
win(g) = 3*2*(2^(BigInt(g)-1)-1) | |
#Calculate the win chance | |
winchance(g) = win(g)//tot(g) | |
xto(n) = range(3,stop=n) | |
yto(n) = map(x-> winchance(x), xto(n)) | |
n=100 #logplot to 100 | |
x = xto(n) | |
y = yto(n) | |
using Plots | |
using PlotThemes | |
theme(:dark) | |
label = "W(g)/T(g)" | |
# Using LaTeX with the default gr backend was not readable so disabled for now. | |
#using LaTeXStrings #Note that LaTeXStrings is Case-Sensitive | |
#label = L"\frac{W(g)}{T(g)}" | |
plot(x,y,label=label,yscale=:log10) | |
xaxis!("Groep van g (>2)") | |
yaxis!("Kans op winnaars (logaritmisch)") | |
png("RPS-log-WTg") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment