Are We Alone?. The Real Odds of Encountering Alien… | by James Gearheart | Sep, 2024


**********************************;
**********************************;
/* Set the random seed for reproducibility */
data _null_;
call streaminit(1234);
run;

/* Number of simulations */
%let num_simulations = 100000;

/* Number of civilizations to generate */
%let num_civilizations = 2364;

/* Galactic radius and height in light years */
%let galactic_radius = 50000;
%let galactic_height = 1300;

/* Earth’s position (assumed to be at 3/4 of the galactic radius) */
%let earth_position_x = &galactic_radius * 3 / 4;
%let earth_position_y = 0;
%let earth_position_z = 0;

/* Create a dataset to store civilization positions */
data civilization_positions;
length Civilization $10.;
input Civilization $ Position_X Position_Y Position_Z;
datalines;
Earth &earth_position_x &earth_position_y &earth_position_z
;
run;

/* Generate random positions for other civilizations */
data civilization_positions;
set civilization_positions;
do i = 1 to &num_civilizations;
Position_X = rand(“Uniform”) * &galactic_radius;
Position_Y = rand(“Uniform”) * 2 * &galactic_height – &galactic_height;
Position_Z = rand(“Uniform”) * 2 * &galactic_height – &galactic_height;
Civilization = “Civilization ” || strip(put(i, 8.));
output;
end;
drop i;
run;

/* Calculate the distance between civilizations and Earth */
data civilization_distances;
set civilization_positions;
Distance = sqrt((Position_X – &earth_position_x)**2 + (Position_Y – &earth_position_y)**2 + (Position_Z – &earth_position_z)**2);
run;

/* Calculate the minimum distance to Earth for each civilization */
proc sql;
create table civilization_min_distance as
select Civilization, Distance as Min_Distance
from civilization_distances
order by Distance;
quit;

/* Calculate the probability of encountering civilizations based on distance */
data probability_encounter;
set civilization_min_distance;
Probability = 1 / (1 + Min_Distance);
run;

/* Calculate the average probability for each distance band */
proc sql;
create table average_probability as
select case
when Min_Distance <= 1000 then ‘Close’
when Min_Distance > 1000 and Min_Distance <= 3000 then ‘Medium’
when Min_Distance > 3000 then ‘Far’
end as Distance_Band,
avg(Probability) as Average_Probability
from probability_encounter
group by case
when Min_Distance <= 1000 then ‘Close’
when Min_Distance > 1000 and Min_Distance <= 3000 then ‘Medium’
when Min_Distance > 3000 then ‘Far’
end;
quit;

/* Print the result */
proc print data=average_probability;
run;

/* Select the closest civilization to Earth and its associated probability */
proc sql;
create table closest_civilization as
select Civilization, Min_Distance, Probability
from probability_encounter
where Min_Distance = (select min(Min_Distance) from probability_encounter);
quit;

/* Print the result */
proc print data=closest_civilization;
run;

/*Bayesian analysis for probability of encountering aliens in the past or future*/

/* Set seed for reproducibility */
%let num_iterations = 100;

/* Create Bayesian analysis dataset */
data bayesian_analysis;
call streaminit(123);

/* Define variables for posterior probabilities */
array posterior_past[&num_iterations];
array posterior_future[&num_iterations];

do i = 1 to &num_iterations;
/* Sample prior probabilities and likelihoods for past encounters */
prior_past = rand(“Uniform”, 0.0001, 0.01); /* P(Past encounter) */
likelihood_past_encounter = rand(“Uniform”, 0.001, 0.1); /* P(No contact | Past encounter) */
likelihood_no_encounter_past = rand(“Uniform”, 0.8, 0.99); /* P(No contact | No encounter) */

/* Calculate posterior probability for past encounter using Bayes’ Theorem */
numerator_past = prior_past * likelihood_past_encounter;
denominator_past = numerator_past + (1 – prior_past) * likelihood_no_encounter_past;
posterior_past[i] = numerator_past / denominator_past;

/* Sample prior probabilities and likelihoods for future encounters */
prior_future = rand(“Uniform”, 0.001, 0.05); /* P(Future encounter) */
likelihood_future_encounter = rand(“Uniform”, 0.01, 0.1); /* P(No contact | Future encounter) */
likelihood_no_encounter_future = rand(“Uniform”, 0.8, 0.99); /* P(No contact | No encounter) */

/* Calculate posterior probability for future encounter using Bayes’ Theorem */
numerator_future = prior_future * likelihood_future_encounter;
denominator_future = numerator_future + (1 – prior_future) * likelihood_no_encounter_future;
posterior_future[i] = numerator_future / denominator_future;
end;

/* Output the results */
do i = 1 to &num_iterations;
posterior_past_value = posterior_past[i];
posterior_future_value = posterior_future[i];
output;
end;
keep posterior_past_value posterior_future_value;
run;

/* Summary statistics for the posterior probabilities */
proc means data=bayesian_analysis mean std min max;
var posterior_past_value posterior_future_value;
run;

/* Distribution histograms for the posterior probabilities */
proc sgplot data=bayesian_analysis;
histogram posterior_past_value / transparency=0.5 fillattrs=(color=blue) binwidth=0.00001;
title “Distribution of Posterior Probabilities for Past Encounters”;
run;

proc sgplot data=bayesian_analysis;
histogram posterior_future_value / transparency=0.5 fillattrs=(color=green) binwidth=0.0001;
title “Distribution of Posterior Probabilities for Future Encounters”;
run;

Recent Articles

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here