Skip to content

Commit

Permalink
Added margin to figures so it won't cut off?
Browse files Browse the repository at this point in the history
  • Loading branch information
ph-kev committed Oct 26, 2023
1 parent 0d604cc commit a115a65
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Measures = "442fdcdd-2543-5da2-b0f3-8c86c306513e"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
WAV = "8149f6b0-98f6-5db9-b78f-408fbbb8ef88"
Expand Down
6 changes: 3 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ pages = [
]
)

deploydocs(
repo = "github.com/ph-kev/ChaoticMessages.jl.git",
)
# deploydocs(
# repo = "github.com/ph-kev/ChaoticMessages.jl.git",
# )
7 changes: 4 additions & 3 deletions docs/src/convergence.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ using ChaoticMessages
using Plots
using DifferentialEquations
using LaTeXStrings
using Measures
u0 = [2.2,1.3,2.0] # initial conditions
p = [16.0;4.0;45.6] # parameters
Expand All @@ -41,7 +42,7 @@ prob_T = ODEProblem(lorenz_transmitter!, u0, tspan, p)
sol_transmitter = solve(prob_T, AutoTsit5(Rodas4P()), abstol = 1e-11, reltol = 1e-11)
# Plot only the x-component of the solution for transmitter's dynamical system
transmitter_plot = plot(sol_transmitter, idxs = (0, 1), legend = false, xaxis=L"t", yaxis="Transmitter",linecolor="black")
transmitter_plot = plot(sol_transmitter, idxs = (0, 1), legend = false, xaxis=L"t", yaxis="Transmitter",linecolor="black", left_margin=10mm, bottom_margin=10mm)
```

Next, we find the solution to the receiver's dynamical system with the same parameters ``\sigma = 16``, ``r=45.6``, and ``b=4`` as before, but with different initial condition ``[10.2,7.3,6.0]``. Also, notice that in the definition of the receiver's system, we are using ``x_T`` which is the $x$-coordinate of the transmitter's dynamical system. Hence, the receiver's dynamical system have some information about the transmitter's dynamical system.
Expand All @@ -59,7 +60,7 @@ prob_R = ODEProblem(receiver!,u0,tspan,p) # reusing the same parameters
sol_receiver = solve(prob_R, AutoTsit5(Rodas4P()), abstol = 1e-11, reltol = 1e-11)
# Plot only the x-component of the solution for receiver's dynamical system
receiver_plot = plot(sol_receiver, idxs = (0, 1), legend = false, xaxis=L"t", yaxis="Receiver",linecolor="black")
receiver_plot = plot(sol_receiver, idxs = (0, 1), legend = false, xaxis=L"t", yaxis="Receiver", linecolor="black", left_margin=10mm, bottom_margin=10mm)
```

Lastly, we plot the absolute error between the $x$-component of the receiver's dynamical system and the transmitter's dynamical system. We see that the error converge to zero which means the pair of dynamical system synchronize despite starting at different initial conditions. Also, it has been shown that the error converge to zero in $O(t^2)$ time. The idea behind sending secret messages using chaotic dynamical systems is to encode a message in $x_T$ and having the receiver's dynamical system reproduce the message by its synchronization!
Expand All @@ -75,5 +76,5 @@ error_plot = plot(abs_error, tspan..., legend = false, xaxis=L"t", yaxis=L"E(t)"
x_coord_plot = plot(x_at_time_t_transmitter, tspan...,label="Transmitter",xaxis=L"t",yaxis=L"x(t)")
plot!(x_at_time_t_receiver, tspan...,label="Receiver")
combined_plot = plot(x_coord_plot, error_plot, dpi=600)
combined_plot = plot(x_coord_plot, error_plot, dpi=600, left_margin=10mm, bottom_margin=10mm)
```
5 changes: 3 additions & 2 deletions docs/src/sending_a_binary_message.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using ChaoticMessages
using Plots
using DifferentialEquations
using LaTeXStrings
using Measures
```

We first encode a binary string into a function of time. If the binary digit is $0$, then the result is `b_zero = 4.0` and if the binary digit is $1$, then the result is `b_one = 4.4`. Each digit is spaced by a time interval of $t=2$. Anything else that do not correspond to any of the position of the binary string is mapped to the value of `b_zero`.
Expand Down Expand Up @@ -48,7 +49,7 @@ secret_message = create_secret_message(
binary = true,
)
plot(secret_message, tspan..., xticks = 0:2:12, legend = false, xaxis=L"t", yaxis="Transmitter",linecolor="black")
plot(secret_message, tspan..., xticks = 0:2:12, legend = false, xaxis=L"t", yaxis="Transmitter",linecolor="black", left_margin=10mm, bottom_margin=10mm)
```

To decrypt the secret message, we use the receiver's dynamical system which is
Expand All @@ -73,7 +74,7 @@ error_squared = decrypt_secret_message(
binary = true
)
p = plot(error_squared, tspan..., xticks = 0:2:12, xaxis=L"t", yaxis="Error squared",linecolor="black")
p = plot(error_squared, tspan..., xticks = 0:2:12, xaxis=L"t", yaxis="Error squared",linecolor="black", left_margin=10mm, bottom_margin=10mm)
for i in [0, 4, 8]
vspan!(p, [i, i + 2], linecolor = :red, fillcolor = :red, fillalpha = 0.2, legend = false)
Expand Down
7 changes: 4 additions & 3 deletions docs/src/sending_a_message.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ using Plots
using DifferentialEquations
using LaTeXStrings
using Random
using Measures
u0 = [2.2,1.3,2.0] # initial condition
p = [16.0, 4.0, 45.6] # parameters of the dynamical system
Expand All @@ -31,7 +32,7 @@ no_message = create_secret_message(u0, p, tspan, (t) -> 0.0)
# Plotting unscaled secret message
time_arr = range(tspan..., length = 100000)
plot(time_arr, unscaled_secret_message, xaxis=L"t", yaxis=L"x(t)", label = "Secret message embedded", color = "lightblue")
plot(time_arr, unscaled_secret_message, xaxis=L"t", yaxis=L"x(t)", label = "Secret message embedded", color = "lightblue", left_margin=10mm, bottom_margin=10mm)
plot!(time_arr, no_message, label = "No message embedded", color = "darkorange")
```

Expand Down Expand Up @@ -79,7 +80,7 @@ abs_error = error_set_up(unencrypted_message, decrypted_message)
error_plot = plot(abs_error, tspan..., legend = false, xaxis=L"t", yaxis=L"E(t)", color = "red", linewidth=0.5)
# Plot unencrypted message and encrypted message
sound_plot = plot(unencrypted_message,tspan...,label="Original", xaxis=L"t", yaxis="Amplitude", color = "blue", linewidth=0.1)
sound_plot = plot(unencrypted_message,tspan...,label="Original", xaxis=L"t", yaxis="Amplitude", color = "blue", linewidth=0.1, left_margin=10mm, bottom_margin=10mm)
plot!(sound_plot, decrypted_message,tspan...,label="Recovered", linewidth=1.5, linealpha=0.3, color = "green")
combined_plot = plot(sound_plot, error_plot, dpi = 900)
Expand All @@ -93,7 +94,7 @@ Random.seed!(42424242) # set seed
message_unencrypted, _, _ = convert_message_to_samples("../audio/taunt.wav")
error_plot = plot()
error_plot = plot(left_margin=10mm, bottom_margin=10mm)
# plot error for various levels of standard deviation
for s in [2.0, 1.0, 0.5, 0.1]
# Create secret message
Expand Down

0 comments on commit a115a65

Please sign in to comment.