Skip to content

Commit

Permalink
Added to functions.jl--
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelnehrer02 committed Dec 21, 2023
1 parent 891994c commit 4b3f756
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ActiveInference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module ActiveInference
include("functions.jl")

# From functions.jl
export plot_beliefs, plot_gridworld, plot_likelihood, create_B_matrix, onehot, plot_point_on_grid, infer_states, get_expected_states, get_expected_observations, calculate_G, run_active_inference_loop, construct_policies, calculate_G_policies, compute_prob_actions,active_inference_with_planning
export array_of_any, array_of_any_zeros, plot_beliefs, plot_gridworld, plot_likelihood, create_B_matrix, onehot, plot_point_on_grid, infer_states, get_expected_states, get_expected_observations, calculate_G, run_active_inference_loop, construct_policies, calculate_G_policies, compute_prob_actions,active_inference_with_planning

# From maths.jl
module Maths
Expand Down
15 changes: 15 additions & 0 deletions src/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ using LinearAlgebra
using Plots



"""Creates an array of "Any" with the desired number of sub-arrays"""
function array_of_any(num_arr::Int)
return Array{Any}(undef, num_arr) #saves it as {Any} e.g. can be any kind of data type.
end

"""Creates an array of "Any" with the desired number of sub-arrays filled with zeros"""
function array_of_any_zeros(shape_list)
arr = Array{Array{Float64, 1}}(undef, length(shape_list))
for (i, shape) in enumerate(shape_list)
arr[i] = zeros(Float64, shape)
end
return arr
end

"""Function for Plotting Beliefs"""
function plot_beliefs(belief_dist, title_str="")
if abs(sum(belief_dist) - 1.0) > 1e-6
Expand Down

0 comments on commit 4b3f756

Please sign in to comment.