The task is to do a statistical analysis of two remarkable fictitious cities, Twinkle and Sprinkle, that form a natural experiment. Twinkle and Sprinkle are practically equivalent, all possible variables having been controlled.

Twinkle and Sprinkle is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

The task details are contained in the Python reference implementation.

This task started out as one to statistically analyze the epidemiologies of two cities in France. I had started researching on the net, looking for statistical packages I might want to use, or algorithms I might implement, when I remembered the famous motto from R. W. Hamming's Numerical Methods for Scientists and Engineers (Dover, 1986):

THE PURPOSE OF COMPUTING IS INSIGHT, NOT NUMBERS

So I went ahead and wrote a Python program that, instead of crunching numbers, depended on the human brain to gain insight enough to hard code in the correct numbers. Perhaps your program will contain different numbers.

Phix

Translation of: Python

See Python entry for explanatory comments (which have been omitted for clarity)

with javascript_semantics
constant txt = """
   Heart attack rates, according to logical inference
                       Women        Men        Overall
 Twinkle (predicted)     0           1           0.5
 Sprinkle (observed)     0           1           0.5

   Heart attack rates, according to the incurious
                       Women        Men        Overall
 Twinkle (predicted)    ???         ???          ???
 Sprinkle (observed)     0           1           0.5

   Heart attack rates, according to Dr. Godzilla
                       Women        Men        Overall
 Twinkle (predicted)     0           0            0
 Sprinkle (observed)     0           1           0.5

   Heart attack rates, according to observers
                       Women        Men        Overall
 Twinkle (observed)      0           1           0.5
 Sprinkle (observed)     0           1           0.5

   Output of an AI of a "Godzilla's theorem" adherent
However strange it may seem, heart attacks in Twinkle and
Sprinkle are now scientifically proven to involve some kind
of violation of causal reality.

   Output of an AI of a very intellectual person
Adherents to "Godzilla's theorem" are society's greatest
geniuses, so what they say is true.

"""
puts(1,txt)

Output same as Python

Python

#!/bin/env python
######################################################################
#
# In his famous and highly respected paper, "Bertlmann's socks and the
# nature of reality" (available open access at
# https://cds.cern.ch/record/142461/ ), the physicist John S. Bell
# asserts that, if we could control the temperature, and control for
# family quarrels, and so on, then the rates of heart attack in Lille
# and Lyon would be statistically independent (Equation 10). His
# defense of this assertion is that "it seems reasonable to expect".
#
# "It seems reasonable to expect" is, of course, not a defense at
# all. And there is an actual mathematical theory of probability that
# Bell is blithely ignoring, or perhaps did not even know about, that
# says this expectation is unreasonable. But let us ask: to what
# purpose is he making this claim?  It is to justify the assumption
# that two variables can be treated as independent parameters (rather
# than as functions of other parameters), even if the two variables
# describe objects that have a common origin.
#
# By such reasoning, my siblings and I must have statistically
# independent DNA! For the only thing our DNAs have to explain any
# correlation is that share a common origin. Hold as many variables
# constant as you want, it will make no difference in the
# correlation. For this reason, I can hardly believe anyone doesn’t
# simply burst out laughing, when reading Bell's writing. But this
# writing is, in fact, mandatory doctrine not only in physics
# departments, but wherever quantum computers are dealt with.
#
# But let us, as amateur and professional computer programmers, not
# burst out laughing, but instead use our computers to examine what
# happens if we assume two cities have the same temperature, the same
# quarreling behaviors, etc., and--this is crucial--whose populations
# share a common origin.
#
# I do not expect either our programs or what I said above about
# sibling DNA to make the slightest difference with physicists and
# quantum computer researchers. They believe what they believe. But we
# are programmers of binary digital computers: probably not also
# quantum physicists, and surely not "qubit" programmers. So let us
# use our computers to enlighten at least ourselves. For, to quote
# Richard Hamming:
#
#       THE PURPOSE OF COMPUTING IS INSIGHT, NOT NUMBERS
#
# I had set out to try to write a fancy Five-Thirty-Eight simulation,
# seeking insight into the matter. I looked into using GNU R to do
# statistically analysis, and so one, but soon realized that to do so
# would produce as much INSIGHT as do Five-Thirty-Eight's fancy
# simulations. Which is to say: none at all.
#
# Instead I came up with the following story.
#
######################################################################
#
# Our story runs as follows:
#
# The cities of Twinkle and Sprinkle always have the same temperature,
# same weather, same day length, same time zone. They always have the
# same quarreling behavior. Everybody eats practically the same things
# and practically at the same times. The two cities have
# indistinguishable sleep habits. They share their water supply. So on
# and so on and so on.
#
# In fact, let us go so far as to say that Twinkle and Sprinkle have
# exactly the same population. Not only that, but exactly half the
# population of each city is women cloned from the same woman, and
# half the population is men cloned from the same man. We shall
# further assume that the two progenitors were genetically sterile, so
# that there are no children in either Twinkle or Sprinkle. Everyone,
# in fact, is exactly the same age. There is no mutation or genetic
# drift.
#
# We could say much more, but you get the idea. We have controlled
# every variable there is: not just every variable we can think of,
# but literally every variable there IS. One of which is: the rate of
# heart attacks. Let us say that no one in either Twinkle or Sprinkle
# ever, ever has a heart attack.
#
# Let us now more closely examine the two progenitors. We discover
# that the male progenitor, but not the female progenitor, had a
# peculiarity of the DNA: that the sound of the "Lady Beware Alarm"
# device of the movie "Invasion of Astro-Monster"
# (https://godzilla.fandom.com/wiki/Invasion_of_Astro-Monster) causes
# instant heart attack.
#
# On a sunny day in July, suddenly it is raining "Lady Beware Alarm"
# devices on Sprinkle, and the devices are blaring at full blast. We
# observe Sprinkle and see that all the men have heart attacks, but
# none of the women do.
#
# We have not observed events in Twinkle. However, we know about the
# pecularity of the DNA, and we know that, as with everything else,
# rainfall in Twinkle is the same as in Sprinkle. We know this to be
# true even if the rain is made of electronic devices instead of
# water, because the two cities are controlled for every variable. Not
# only variables we thought of, but literally every every variable
# there is.
#
# Here we come to the use of a computer to gain insight.
#
# Write code to compute and print the heart attack rates for that July
# day in Twinkle and Sprinkle. The rates in Sprinkle are the observed
# ones, but the rates in Twinkle are predicted by inference.
#

print ()
print ("   Heart attack rates, according to logical inference")
print ("                       Women        Men        Overall")
print (" Twinkle (predicted)     0           1           0.5")
print (" Sprinkle (observed)     0           1           0.5")
print ()

#
# Now assume, against all common sense and soundness of logic, that
# heart attacks in Twinkle cannot be predicted from heart attacks in
# Sprinkle. We have controlled for all variables, but we also assume
# common origin is irrelevant.
#
# Write code to compute and print out the heart attack rates,
# according to that way of thinking.
#

print ("   Heart attack rates, according to the incurious")
print ("                       Women        Men        Overall")
print (" Twinkle (predicted)    ???         ???          ???")
print (" Sprinkle (observed)     0           1           0.5")
print ()

#
# According to such theory, there is nothing we can predict about
# Twinkle. What happens in Twinkle will remain a complete mystery
# until we go there and observe.
#
# But further suppose we have a so-called "Godzilla's theorem", which
# quotes no postulates or theorems known to mathematics, but which
# instead introduces this postulate: that men having heart attacks in
# Sprinkle would have to have a causal influence on heart attack rates
# in Twinkle, for Twinkle's heart attack rates to change. This is so
# because we have controlled all variables and the "residual
# fluctuations" can be integrated out (as in Bell's Equation 10). The
# two cities are utterly the same. The only difference is we have
# observed the men in Sprinkle have heart attacks and have not
# observed Twinkle at all.
#
# Write code to compute and print out the heart attack rates predicted
# by "Godzilla's theorem".
#

print ("   Heart attack rates, according to Dr. Godzilla")
print ("                       Women        Men        Overall")
print (" Twinkle (predicted)     0           0            0")
print (" Sprinkle (observed)     0           1           0.5")
print ()

#
# Now we go into Twinkle and observe that all the men have had heart
# attacks, but none of the women have.
#
# Write code to compute and print out the observed heart attack rates.
#

print ("   Heart attack rates, according to observers")
print ("                       Women        Men        Overall")
print (" Twinkle (observed)      0           1           0.5")
print (" Sprinkle (observed)     0           1           0.5")
print ()

#
# These empirical results stand in stark contrast to our prediction,
# which was predicated on the assumption of "causal reality".
#
# Write Artificial Intelligence code to print out the conclusion of
# adherents to "Godzilla's theorem".
#

print ("   Output of an AI of a \"Godzilla's theorem\" adherent")
print ("However strange it may seem, heart attacks in Twinkle and")
print ("Sprinkle are now scientifically proven to involve some kind")
print ("of violation of causal reality.")
print ()

#
# Then write Artificial Intelligence code to print out the conclusion
# of the educated public.
#

print ("   Output of an AI of a very intellectual person")
print ("Adherents to \"Godzilla's theorem\" are society's greatest")
print ("geniuses, so what they say is true.")
print ()

#
# That was the tale of two remarkable cities, Twinkle and Sprinkle.
#
# Okay. Now what do YOU, who just wrote a program for the purpose of
# gaining insight, think? What insight have you gained?
#
# In the end, we are all individually responsible for what we think,
# even if we got it by deferring to "scientific authority".
#
# THE END.
#
# Afterword: Those familiar with the debates within physics might
# recognize that the DNA peculiarity is what they would call a "hidden
# variable". The crucial question is this: can a "hidden variable" be
# shared due to a common origin, or can it not? I say it can be, John
# Bell said otherwise. But you must decide for yourself. It is your
# decision, even if that decision is to believe "Whichever of the two
# 'scientific authority' proclaims to be the truth."
#