I don't know Julia. And I don't understand Bayes' Theorem. But it's interesting 
that Swalwell was pressured to resign, given the accusations against Trump. So 
when I originally asked Devstral to write me a julia program to estimate the 
likelihood Swalwell is a harasser, it incremented α (in Β(α,β)). But decrementing 
β better fits my intuition. The output seems reasonable. >8^D

Too bad Swalwell has the organs that respond to shame. He could've been 
president some day, after racking up several more accusations ... and maybe a 
conviction or two.

--
¡sıɹƎ ןıɐH ⊥ ɐןןǝdoɹ ǝ uǝןƃ
ὅτε oi μὲν ἄλλοι κύνες τοὺς ἐχϑροὺς δάκνουσιν, ἐγὰ δὲ τοὺς φίλους, ἵνα σώσω.
using Distributions
using Plots

# Initial parameters
initial_prob_harasser = 0.1  # Initial probability that a random person is a harasser (base rate)
initial_prob_accusation_given_harasser = 0.9  # Probability of accusation if person is a harasser
initial_prob_accusation_given_not_harasser = 0.1  # Probability of false accusation if person is not a harasser

# Prior probability that the accused is a harasser
prior_prob_harasser = initial_prob_harasser

# Function to update probability of being a harasser given a new accusation
function update_prob_harasser(prior_prob_h, prob_acc_given_h, prob_acc_given_not_h)
    # P(H|A) = [P(A|H) * P(H)] / [P(A|H) * P(H) + P(A|~H) * P(~H)]
    likelihood_harasser = prob_acc_given_h * prior_prob_h
    likelihood_not_harasser = prob_acc_given_not_h * (1 - prior_prob_h)
    posterior_prob_h = likelihood_harasser / (likelihood_harasser + likelihood_not_harasser)
    return posterior_prob_h
end

# Function to plot probability and save to file
function plot_probability(probabilities, filename, title="Probability of Being a Harasser")
    p = plot(1:length(probabilities), probabilities,
             title=title,
             xlabel="Number of Accusations",
             ylabel="Probability",
             label="P(H|accusations)",
             ylim=(0,1),
             marker=:circle)
    savefig(p, filename)
    println("Saved plot to $filename")
end

# Simulate receiving additional accusations
function simulate_accusations(initial_prob_h, prob_acc_given_h, prob_acc_given_not_h, num_accusations)
    current_prob_h = initial_prob_h
    probabilities = Float64[]

    for i in 1:num_accusations
        # Update probability with new accusation
        current_prob_h = update_prob_harasser(current_prob_h, prob_acc_given_h, prob_acc_given_not_h)
        push!(probabilities, current_prob_h)

        println("After accusation $i: P(H) = $(round(current_prob_h, digits=4))")
    end

    return probabilities
end

# Run simulation with 18 accusations
println("Updating probability that the accused is a harasser:")
probabilities = simulate_accusations(
    prior_prob_harasser,
    initial_prob_accusation_given_harasser,
    initial_prob_accusation_given_not_harasser,
    18
)

# Plot the probability progression
plot_probability(probabilities, "harasser_probability.png")
.- .-.. .-.. / ..-. --- --- - . .-. ... / .- .-. . / .-- .-. --- -. --. / ... 
--- -- . / .- .-. . / ..- ... . ..-. ..- .-..
FRIAM Applied Complexity Group listserv
Fridays 9a-12p Friday St. Johns Cafe   /   Thursdays 9a-12p Zoom 
https://bit.ly/virtualfriam
to (un)subscribe http://redfish.com/mailman/listinfo/friam_redfish.com
FRIAM-COMIC http://friam-comic.blogspot.com/
archives:  5/2017 thru present https://redfish.com/pipermail/friam_redfish.com/
  1/2003 thru 6/2021  http://friam.383.s1.nabble.com/

Reply via email to