Skip to content

Commit

Permalink
julia formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
pasq-cat committed Jul 23, 2024
1 parent 52fa6ae commit e6c0128
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
3 changes: 2 additions & 1 deletion src/LaplaceRedux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ include("calibration_functions.jl")
export empirical_frequency_binary_classification,
sharpness_classification,
empirical_frequency_regression,
sharpness_regression, extract_mean_and_variance,
sharpness_regression,
extract_mean_and_variance,
sigma_scaling
end
2 changes: 1 addition & 1 deletion src/calibration_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,4 @@ function sigma_scaling(
sigma = sqrt(1 / length(y_cal) * sum(norm.(y_cal .- means) ./ variances))

return sigma
end
end
51 changes: 25 additions & 26 deletions test/calibration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -326,34 +326,33 @@ end
)
end


# Test for `empirical_frequency_binary_classification` function
@testset "sigma scaling" begin
@info "testing sigma scaling technique"
# Test 1: testing function extract_mean_and_variance
# Create 3 different Normal distributions with known means and variances
known_distributions = [Normal(0.0, 1.0), Normal(2.0, 3.0), Normal(-1.0, 0.5)]
expected_means = [0.0, 2.0, -1.0]
expected_variances = [1.0, 9.0, 0.25]
# Execution: Call the function
actual_means, actual_variances = extract_mean_and_variance(known_distributions)
@test actual_means expected_means
@test actual_variances expected_variances
# Create 3 different Normal distributions with known means and variances
known_distributions = [Normal(0.0, 1.0), Normal(2.0, 3.0), Normal(-1.0, 0.5)]
expected_means = [0.0, 2.0, -1.0]
expected_variances = [1.0, 9.0, 0.25]
# Execution: Call the function
actual_means, actual_variances = extract_mean_and_variance(known_distributions)
@test actual_means expected_means
@test actual_variances expected_variances
# Test 2: testing sigma_scaling
# Step 1: Define the parameters for the sine wave
start_point = 0.0 # Start of the interval
end_point = 2 * π # End of the interval, 2π for a full sine wave cycle
sample_points = 2000 # Number of sample points between 0 and 2π

# Step 2: Generate the sample points
x = LinRange(start_point, end_point, sample_points)

# Step 3: Generate the sine wave data
y = sin.(x)
distrs = Distributions.Normal.(y, 0.01)
#fake miscalibrated predictions
predicted_elements = rand.(distrs) .+ rand((1,2))
sigma = sigma_scaling( distrs ,predicted_elements)
@test typeof(sigma) <: Number
end
# Step 1: Define the parameters for the sine wave
start_point = 0.0 # Start of the interval
end_point = 2 * π # End of the interval, 2π for a full sine wave cycle
sample_points = 2000 # Number of sample points between 0 and 2π

# Step 2: Generate the sample points
x = LinRange(start_point, end_point, sample_points)

# Step 3: Generate the sine wave data
y = sin.(x)
distrs = Distributions.Normal.(y, 0.01)
#fake miscalibrated predictions
predicted_elements = rand.(distrs) .+ rand((1, 2))

sigma = sigma_scaling(distrs, predicted_elements)
@test typeof(sigma) <: Number
end

0 comments on commit e6c0128

Please sign in to comment.