[Article] The Frequency of Serial Killer Conspiracies from Wikipedia Data

Serial Killer Conspiracies

Another brief followup to my article on the rationality of conspiracy theories. It is a common belief among intellectuals that “conspiracy theories” are inherently irrational or so unlikely as to be essentially inherently irrational.

The dictionary — as opposed to popular pejorative propaganda meaning — of “conspiracy theory” is simply a theory or hypothesis that some illegal or harmful event was caused by two or more malefactors working together. When surviving family, friends and neighbors, police investigators, news reporters or others suspect two or more perpetrators in a murder, they must consider a conspiracy theory.

The popular propaganda redefinition of “conspiracy theory,” the most straightforward dictionary phrase for a conspiracy theory, as “an irrational theory contradicted by evidence and reason” makes it difficult even to discuss and consider actual conspiracies in the modern world — not unlike the fictional newspeak in George Orwell’s dystopian novel 1984.

United States FBI (Federal Bureau of Investigation) Homicide Statistics for 2019

A high fraction of events where the phrase “conspiracy theory” is used to stigmatize suspicions of a criminal conspiracy are murders such as the assassination of President Kennedy or possible murders such as the suspicious “suicide” of financier Jeffrey Epstein where the suspected criminal conspiracy involves powerful persons such as high government officials, politicians, business leaders, or others. According to official FBI statistics about 14.7 percent of murders in 2019 were committed by multiple offenders, a conspiracy in common usage.

Almost twenty-seven percent (27%) of murders in 2019 were unsolved. Unsolved murders tend to be gang violence/organized crime murders, that is conspiracies that could not be proven. The larger, the more powerful, and the more secret a gang or organized crime group is perceived to be, the less willing witnesses are to come forward with testimony and evidence.

Official government numbers may be inaccurate due to political pressure, bias, or error. For example, serious questions have been raised about the FBI’s estimates of the number of serial killers and serial homicides in the early 1980s.

As a partial check on the FBI’s official numbers on murders with multiple offenders, I previously analyzed the frequency of conspiracies in high profile “serial killer” murder cases listed in Jack Rosewood’s Big Book of Serial Killers which lists one-hundred and fifty cases from around the world, mostly the United States. This analysis indicated about 5-10% of cases were serial killer conspiracies. Here I present a more extensive analysis of Wikipedia’s list of serial killers in the United States page, which has 553 serial killers reportedly active in the United States from 1950 to 2020 (I omitted the pre-1950 cases listed on the Wikipedia page).

Wikipedia List of serial killers in the United States screenshot (November 27, 2022)

Methods

The data was extracted from the Wikipedia page identified serial killers table to a CSV (comma separated values) file on August 18, 2022 for another analysis to understand the properties and possible causes of serial murders, notably the seeming 1970s-1980s serial killer wave. The analysis is done using the Python programming language, NumPy, SciPy, and Matplotlib.

The table includes a Notes column which enables identification of cases where there was one or more accomplice. The language “accomplice,” “accomplices,” “with partner”, “with husband,” “with wife,” and similar phrases is generally used to identify accomplices. Some accomplices are listed separately in the Name column of the table; some are not. Serial killers reportedly active in the United States from 1950 to 2020 were analyzed.

The accomplices refer to persons convicted in a court of law. They do not include unsubstantiated claims by the serial killer, suspects never convicted including named or unnamed suspects suggested in books such as Maury Terry’s The Ultimate Evil or Dave McGowan (no relation)’s Programmed to Kill. As discussed in my previous article, there is evidence of additional accomplices, never convicted, in a number of cases listed by Wikipedia with no accomplices in the Notes section. These include John Wayne Gacy, Patrick Kearney, Randy Kraft, and several others. These “maybe” serial killer conspiracies are not included in the results below which count only convicted accomplices.

The Wikipedia list of serial killers in the United States is extensive, appears correct, but there may be some errors.

The plot below gives a rough overview of the serial killer conspiracy cases — fifty-six (56) named serial killers out of 553 reportedly active from 1950 to 2020. This is 10.13% of the names listed in the table. The error is roughly 1.4% giving a ninety-five percent confidence interval of about 7.9% to 13.2% of identified serial killer cases involve conspiracies — have accomplices. Both the number of proven victims and the number of serial killers active peaks during the 1970s and 1980s, declining substantially in the 1990s up to 2020.

The green bars show the dates the serial killer and accomplices were active. The red circle shows the middle of this date range. The horizontal axis is the date in year. The vertical axis is the number of proven victims from the table. The red circles are labeled with the names of all identified serial killers from the table with the same middle of the date range. This shows some of the accomplices/conspirators. The data in the table, especially the notes column, is inconsistently presented, resulting in some serial killers not being grouped together. For example, Elmer Wayne Henley and Dean Corll, both shown in the plot, were accomplices. The table appears to credit Henley with only six (6) of the proven twenty-eight (28) murders organized by Corll, the ringleader.

Conclusion

Thus, proven in a court of law conspiracies are a small but significant fraction, about 10 percent (8-13% ninety-five percent confidence interval), of prominent serial killer cases — smaller than the 14.7 percent of murders with multiple offenders according to the FBI (in 2019). This is not surprising given the generally solitary nature of the crimes. Nonetheless, conspiracies are not exceptionally rare or unusual even in this type of murder.

Appendix: Deep Dive into Analysis

ACCOMPLICE CASES (56)
CASE NOTES MATCH AT LEAST ONE OF: accomplice, with wife, with husband, cult , accompliace, with his wife, with her husband, killers, partnership, with the aid of local teenagers
Bianchi, Kenneth Along with accomplice Angelo Buono Jr., known as "The Hillside Stranglers". Murdered young women in Los Angeles and Washington
Bittaker, Lawrence With accomplice Roy Norris known as "The Tool Box Killers"
Bonin, William Known as "The Freeway Killer"; preyed on young men and boys in southern California with several accomplices
Briley Brothers Three brothers and an accomplice responsible for 11 murders
Brown, Debra Denise Accomplice of Alton Coleman
Brummett, Lyle Raped and strangled three women in Texas with an accomplice
Bundy, Carol M. With accomplice Doug Clark, known as "The Sunset Strip Killers"; preyed on young women in West Hollywood and Los Angeles, California
Buono Jr., Angelo Along with accomplice Kenneth Bianchi, known as "The Hillside Stranglers". Murdered young women in Los Angeles
Carson, Michael Bear Along with his wife, Suzan Carson, dubbed "The San Francisco Witch Killers"; considered suspects in nearly a dozen other deaths in the U.S. and Europe[103]
Carson, Suzan Along with her husband, Michael Bear Carson, dubbed "The San Francisco Witch Killers"; considered suspects in nearly a dozen other deaths in the U.S. and Europe[103]
Chavez, Juan Rodriguez Known as "The Thrill Killer"; killed a neighbor during a burglary; paroled and went on a killing spree with a teenage accomplice
Clark, Doug With accomplice Carol M. Bundy, known as "The Sunset Strip Killers"; preyed on young women in West Hollywood and Los Angeles, California
Coffman, Cynthia Kidnapped four women by ATMs before accomplice strangled them
Coleman, Alton Multi-state killer who, along with his accomplice, murdered a man and injured another, murdered four women and three young girls, and raped a young girl
Cooks, Jessie Lee Part of "The Death Angels" cult responsible for the Zebra murders
Copeland, Faye Along with her husband, Ray Copeland, the oldest couple ever sentenced to death in the United States
Copeland, Ray Along with his wife, Faye Copeland, the oldest couple ever sentenced to death in the United States
Corll, Dean Known as "The Candy Man" and "The Pied Piper". Crimes referred to as "The Houston Mass Murders"; raped and murdered boys and young men in Texas with the aid of teenaged accomplices David Owen Brooks and Elmer Wayne Henley
Davis, Girvies Accomplice of Richard Holman; killed robbery witnesses, saying it was "easier" than wearing a mask
Dieteman, Samuel Accomplice Dale Hausner Committed suicide in prison
Gallego, Gerald Accomplice Charlene Gallego released in 1997
Gecht, Robin Member of the satanic cult and organized crime group known as "The Ripper Crew" or "The Chicago Rippers"
Gordon, Steven Dean Sex offender who raped and strangled prostitutes in Santa Ana and Anaheim, California, aided by accomplice Franc Cano
Graham, Gwendolyn Accomplice of Cathy Wood; nurse's aide that preyed on elderly women in a Walker, Michigan nursing home
Green, Larry Part of "The Death Angels" cult responsible for the Zebra murders
Gretzler, Douglas With accomplice Willie Steelman, killed witnesses to their robberies spree across California and Arizona
Henley, Elmer Wayne Crimes referred to as "The Houston Mass Murders"; accomplice of Dean Corll, who he later killed in self-defense
Herzog, Loren Along with accompliace Wesley Shermantine known as "The Speed Freak Killers"
Holman, Richard Accomplice of Girvies Davis; killed robbery witnesses
Kadamovas, Jurijus Accomplice of Iouri Mikhel; Lithuanian immigrant who kidnapped five people for ransom money in California and killed them
Knorr, Theresa Her sons, William and Robert Jr., were accomplices
Knotek, Michelle Tortured and abused boarders in her home with her husband
Kokoraleis, Andrew Member of the satanic cult and organized crime group known as "The Ripper Crew" or "The Chicago Rippers"
Kokoraleis, Thomas Member of the satanic cult and organized crime group known as "The Ripper Crew" or "The Chicago Rippers"
Koster, Brent Teenage accomplice of Danny Ranes, who actively participated in three of his four murders
Lake, Leonard Along with accomplice Charles Ng, they are also known as "The Operation Miranda Killers"
Lewingdon, Gary Together with brother Thaddeus Lewingdon, known as "The .22 Caliber Killers"
Lewingdon, Thaddeus Together with brother Gary Lewingdon, known as "The .22 Caliber Killers"
Malvo, Lee Boyd With accomplice John Allen Muhammad, perpetrated the D.C. sniper attacks
McCoy, Stephen Along with his accomplice, James Paster, the pair murdered three people in the Houston Area
Mikhel, Iouri Accomplice of Jurijus Kadamovas; Russian immigrant who kidnapped five people in California for ransom money and killed them
Moore, Manuel Part of "The Death Angels" cult responsible for the Zebra murders
Muhammad, John Allen With accomplice Lee Boyd Malvo, perpetrated the D.C. sniper attacks
Neelley, Alvin Committed murders with wife Judith Neelley
Neelley, Judith Committed murders with husband Alvin Neelley
Ng, Charles Along with accomplice Leonard Lake, they are also known as "The Operation Miranda Killers"
Norris, Roy With accomplice Lawrence Bittaker known as "Tool Box Killers"
Pardo, Manuel South Florida former police officer who acted in partnership with Rolando Garcia; the two claimed to be ridding the world of drug dealers
Paster, James Along with his accomplice, Stephen McCoy, the pair murdered three people in the Houston Area. Paster confessed to two other murders for which he was never tried.
Ranes, Danny Kidnapped, raped and murdered women around Kalamazoo, Michigan with teenage accomplice Brent Koster
Schmid, Charles Known as "The Pied Piper of Tucson"; murdered three teenage girls in Arizona with the aid of local teenagers
Shermantine, Wesley Along with accompliace Loren Herzog, known as "The Speed Freak Killers"
Simon, J.C.X. Part of "The Death Angels" cult responsible for the Zebra murders
Spreitzer, Edward Member of the satanic cult and organized crime group known as "The Ripper Crew" or "The Chicago Rippers"
Toole, Ottis Accomplice of Henry Lee Lucas; claimed to have murdered Adam Walsh
Wood, Cathy Accomplice of Gwendolyn Graham; nurse's aide that preyed on elderly women in a Walker, Michigan nursing home. Released on January 16, 2020
ACCOMPLICE CASES (56)

References

The Big Book of Serial Killers, Vol 1, by Jack Rosewood
https://www.amazon.com/Big-Book-Serial-Killers-Encyclopedia-ebook/dp/B071K51FQ4/ref=tmm_kin_swatch_0?_encoding=UTF8&qid=&sr=

FBI Expanded Homicide Data Table 4: Murder by Victim/Offender Situations, 2019
https://ucr.fbi.gov/crime-in-the-u.s/2019/crime-in-the-u.s.-2019/topic-pages/tables/expanded-homicide-data-table-4.xls

Using Murder: The Social Construction of Serial Homicide, by Philip Jenkins, Aldine De Gruyter, New York, 1994

“Serial Killer” Conspiracy Cases

Note that the details of these crimes are quite unpleasant and are discussed in these references. The analysis in this article is only concerned with the proportion of cases that were conspiracies as defined in common usage — multiple offenders working together.

Paul Bernardo and Karla Homolka
https://www.thecanadianencyclopedia.ca/en/article/paul-bernardo-and-karla-homolka-case

Kenneth Bianchi and Angelo Buono
https://allthatsinteresting.com/hillside-strangler-kenneth-bianchi-angelo-buono

Lawrence Sigmund Bittaker and Roy Lewis Norris
https://unhbcoe.org/en/Lawrence_Bittaker_and_Roy_Norris-0426802400

William Bonin (and 22-year-old Vernon Butts, as well as teenagers Gregory Miley, William Pugh, and James Munro)
https://www.upi.com/Archives/1982/01/07/Freeway-Killer-William-Bonin-convicted-of-luring-10-youths/3460977293230/

Douglas Clark and Carol Bundy
https://www.oxygen.com/mysteries-scandals/crime-time/carol-bundy-victim-mastermind-sunset-strip-killers

Dean Corll (with Elmer Wayne Henley and David Owen Brooks)
https://murderpedia.org/male.C/c/corll-dean.htm

Delfina and Maria de Jesus Gonzalez
https://justcriminals.info/2016/12/19/delfina-maria-de-jesus-gonzalez/

Patrick Kearney (and David Hill?)
https://criminalminds.fandom.com/wiki/Patrick_Kearney

Randy Steven Kraft and unknown accomplice or accomplices
https://murderpedia.org/male.K/k/kraft-randy.htm

Leonard Lake and Charles Ng
https://www.historicmysteries.com/charles-ng-and-leonard-lake/

John Allan Mohammad and Lee Boyd Malvo
https://stmuscholars.org/john-allen-muhammad-lee-boyd-malvo-the-dc-snipers/

David Ray Parker (and Cindy Hendy and others)
https://allthatsinteresting.com/david-parker-ray-toy-box-killer
https://www.fbi.gov/contact-us/field-offices/albuquerque/items-david-parker-ray
https://www.thescarechamber.com/david-parker-ray-toy-box-of-torture/

Fred West and Rosemary West
https://www.cnn.com/2021/06/04/europe/fred-rosemary-west-murders-gbr-cmd-intl/index.html

Aileen Carol Wuornos (and Tyria Moore, never charged)
https://sites.psu.edu/harringpassion/2019/03/29/aileen-wuornos/

John Wayne Gacy and possible unknown accomplice or accomplices

https://theweek.com/articles/478154/did-serial-killer-john-wayne-gacy-have-accomplices
https://newsfeed.time.com/2012/02/13/serial-killer-john-wayne-gacy-may-have-had-accomplices/
https://chicago.cbslocal.com/2012/02/10/attorneys-believe-gacy-had-accomplices/
https://www.oxygen.com/true-crime-buzz/how-john-wayne-gacy-survivor-jeffrey-rignall-went-on-a-personal-mission
https://www.archiweekend.com/viral-news/how-john-wayne-gacy-survivor-jeffrey-rignall-continued-an-individual-pursuit-to-stop-him-from-hurting-others/

Questions about Jeffrey Epstein “Suicide”

https://www.washingtonpost.com/politics/autopsy-finds-broken-bones-in-jeffrey-epsteins-neck-deepening-questions-around-his-death/2019/08/14/d09ac934-bdd9-11e9-b873-63ace636af08_story.htmlhttps://www.washingtonexaminer.com/news/autopsy-points-to-possibility-epstein-was-strangled-reporthttps://channel933.iheart.com/content/new-evidence-suggests-jeffrey-epstein-was-strangled-dr-michael-baden/

Programmed to Kill: The Politics of Serial Murder, Dave McGowan, August 2004
https://www.amazon.com/Programmed-Kill-Politics-Serial-Murder/dp/0595326404/

The Ultimate Evil: The Search for the Sons of Sam, by Maury Terry, Introduction by Joshua Zeman
https://www.amazon.com/Ultimate-Evil-Search-Sons-Sam-ebook/dp/B08NFVHPP5/

(C) 2022 by John F. McGowan, Ph.D.

About Me

John F. McGowan, Ph.D. solves problems using mathematics and mathematical software, including developing gesture recognition for touch devices, video compression and speech recognition technologies. He has extensive experience developing software in C, C++, MATLAB, Python, Visual Basic and many other programming languages. He has been a Visiting Scholar at HP Labs developing computer vision algorithms and software for mobile devices. He has worked as a contractor at NASA Ames Research Center involved in the research and development of image and video processing algorithms and technology. He has published articles on the origin and evolution of life, the exploration of Mars (anticipating the discovery of methane on Mars), and cheap access to space. He has a Ph.D. in physics from the University of Illinois at Urbana-Champaign and a B.S. in physics

[Article] How to Display Grid Lines in MatPlotLib

"""
Short demo How to Display Grid Lines in MatPlotLib
(C) 2022 by Mathematical Software Inc.
http://www.mathematical-software.com/
"""
# Python Standard Library
import os
import sys
import time
# NumPy and MatPlotLib add on Python packages/modules
import numpy as np
import matplotlib.pyplot as plt
XRANGE = 5.0
CUBE_CONST = 1.5
ACCELERATION = 9.8
VELOCITY = -20.0
x = np.linspace(-XRANGE, XRANGE, 200)
y = CUBE_CONST*x**3 + 0.5*ACCELERATION*x**2 + VELOCITY*x
# simple MatPlotLib plot
f1 = plt.figure()
ax = plt.axes() # get plot axes
ax.set_facecolor('lightgray') # background color of plot
plt.plot(x, y, 'g-')
plt.title('Grid Lines in MatPlotLib DEMO')
plt.xlabel('X')
plt.ylabel(f'Y = {CUBE_CONST:.2f}*X3 + {0.5*ACCELERATION:.2f}*x**2' f' + {VELOCITY:.2f}*x)')
plt.grid(which='major', color='black')
plt.grid(which='minor', color='gray')
plt.minorticks_on() # need this to see the minor grid lines
plt.show(block=True)
f1.savefig('how_to_display_grid_lines_in_matplotlib.jpg',
dpi=300)

(C) 2022 by John F. McGowan, Ph.D.

About Me

John F. McGowan, Ph.D. solves problems using mathematics and mathematical software, including developing gesture recognition for touch devices, video compression and speech recognition technologies. He has extensive experience developing software in C, C++, MATLAB, Python, Visual Basic and many other programming languages. He has been a Visiting Scholar at HP Labs developing computer vision algorithms and software for mobile devices. He has worked as a contractor at NASA Ames Research Center involved in the research and development of image and video processing algorithms and technology. He has published articles on the origin and evolution of life, the exploration of Mars (anticipating the discovery of methane on Mars), and cheap access to space. He has a Ph.D. in physics from the University of Illinois at Urbana-Champaign and a B.S. in physics from the California Institute of Technology (Caltech).

[Video/Article] How to Get Standard Normal Function in Python

https://www.youtube.com/shorts/V-yssaFYwvY

Short video on how to get the standard Normal/Gaussian/Bell Curve function in Python without writing your own implementation which is complex and error prone.

# Example of Standard Bell Curve Function in Python
from matplotlib import pyplot as plt
import numpy as np
import math  # no Gaussian function

# Get scipy add on module from scipy.org
from scipy.stats import norm  # Gaussian function in scipy.stats


# Custom Gaussian/Normal/Bell Curve custom function
def gaussian(x, mean, sigma):
    return 1./(math.sqrt(2.0*math.pi)*sigma)\
        * np.exp(-0.5*np.power((x - mean)/sigma, 2.))


x = np.linspace(-3, 3, 100)
# plt.plot(gaussian(x, 0.0, 1.0))
plt.plot(norm.pdf(x, loc=0.0, scale=1.0))
plt.grid(True)
plt.show()

(C) 2022 by John F. McGowan, Ph.D.

About Me

John F. McGowan, Ph.D. solves problems using mathematics and mathematical software, including developing gesture recognition for touch devices, video compression and speech recognition technologies. He has extensive experience developing software in C, C++, MATLAB, Python, Visual Basic and many other programming languages. He has been a Visiting Scholar at HP Labs developing computer vision algorithms and software for mobile devices. He has worked as a contractor at NASA Ames Research Center involved in the research and development of image and video processing algorithms and technology. He has published articles on the origin and evolution of life, the exploration of Mars (anticipating the discovery of methane on Mars), and cheap access to space. He has a Ph.D. in physics from the University of Illinois at Urbana-Champaign and a B.S. in physics from the California Institute of Technology (Caltech).

[Python] How to compute future date with millisecond precision and timezone displayed

Use the Python datetime module as follows:

# [Python] How to compute future date with millisecond precision and timezone displayed
import datetime
wait_duration_dt = datetime.timedelta(days=400, hours=2, minutes=30)  # expected wait
today_dt = datetime.datetime.now()  # current date/time in local time zone
future_date_time = today_dt + wait_duration_dt  # compute future date
# get human readable local time zone
LOCAL_TIMEZONE = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo
print(future_date_time, LOCAL_TIMEZONE)

(C) 2022 by John F. McGowan, Ph.D.

About Me

John F. McGowan, Ph.D. solves problems using mathematics and mathematical software, including developing gesture recognition for touch devices, video compression and speech recognition technologies. He has extensive experience developing software in C, C++, MATLAB, Python, Visual Basic and many other programming languages. He has been a Visiting Scholar at HP Labs developing computer vision algorithms and software for mobile devices. He has worked as a contractor at NASA Ames Research Center involved in the research and development of image and video processing algorithms and technology. He has published articles on the origin and evolution of life, the exploration of Mars (anticipating the discovery of methane on Mars), and cheap access to space. He has a Ph.D. in physics from the University of Illinois at Urbana-Champaign and a B.S. in physics from the California Institute of Technology (Caltech).

[Python] How to get function signature

How to get function signature in Python

Use:

import inspect
function_signature = inspect.signature(function_reference)

Full Example

#
# [Python] How to get function signature
#
import inspect

def myfunc(a, b, multiplier=1.0):
    return multiplier*(a + b)

print("myfunc(1,2) is:", myfunc(1,2))

sig = inspect.signature(myfunc)

msg = "function signature is: " + str(sig)
print(msg)

Note that the signature sig above is not a string (a Python str object). Must be cast to a Python str to concatenate with a string as shown in computing msg.

Python demonstration code output

(C) 2022 by John F. McGowan, Ph.D.

About Me

John F. McGowan, Ph.D. solves problems using mathematics and mathematical software, including developing gesture recognition for touch devices, video compression and speech recognition technologies. He has extensive experience developing software in C, C++, MATLAB, Python, Visual Basic and many other programming languages. He has been a Visiting Scholar at HP Labs developing computer vision algorithms and software for mobile devices. He has worked as a contractor at NASA Ames Research Center involved in the research and development of image and video processing algorithms and technology. He has published articles on the origin and evolution of life, the exploration of Mars (anticipating the discovery of methane on Mars), and cheap access to space. He has a Ph.D. in physics from the University of Illinois at Urbana-Champaign and a B.S. in physics from the California Institute of Technology (Caltech).

[Python] How to plot text in normalized coordinates in matplotlib

Normalized coordinates refers to plot coordinates where the horizontal and vertical axes run from 0.0 to 1.0 or zero percent to 100 percent of the plot dimensions. One often wants to position text labels or annotations in this way. This is NOT the default for the plt.text(…) function in matplotlib, the plotting add on module for Python that emulates MATLAB style plotting.

The key functions in matplotlib for normalized coordinates are:

ax = plt.gca()  # get the current axes of the plot
plt.text(x, y, "my text", transform=ax.transAxes, fontsize)

This is a short program showing the full use of these two function in context.

# How to plot text in normalized coordinates (0, 1) in matplotlib
# ax = plt.gca()  # get current plot axes object
# plt.text(x, y, string_message, transform = ax.transAxes, fontsize)

import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0.0, 10.0, 100)
y = 10*x**2
fig = plt.figure()
plt.title("How to plot text in normalized coordinates in matplotlib", fontsize=8)
plt.plot(x, y, 'g-', label='parabola')
# Plot text in normalized (0.0, 1.0) coordinates in matplotlib
ax = plt.gca()  # get current plot axes object
# NOTE: lowercase first letter of transAxes below
Y_POS = 0.91  # in range 0.0 to 1.0 (100%)
this_text = f"plt.text(0.01, {Y_POS}, \"this text\", transform=ax.transAxes"
plt.text(0.01, 0.95, "ax = plt.gca()", transform=ax.transAxes)
plt.text(0.01, Y_POS, this_text, transform=ax.transAxes)
#
plt.minorticks_on()
plt.grid(True, which='major', color='k')
plt.grid(True, which='minor')
plt.xlabel('X')
plt.ylabel('Y')
plt.show()
fig.savefig('matplotlib_normalized_coordinates.jpg', dpi=72)
Output Plot with key function text positioned in normalized coordinates

(C) 2022 by John F. McGowan, Ph.D.

About Me

John F. McGowan, Ph.D. solves problems using mathematics and mathematical software, including developing gesture recognition for touch devices, video compression and speech recognition technologies. He has extensive experience developing software in C, C++, MATLAB, Python, Visual Basic and many other programming languages. He has been a Visiting Scholar at HP Labs developing computer vision algorithms and software for mobile devices. He has worked as a contractor at NASA Ames Research Center involved in the research and development of image and video processing algorithms and technology. He has published articles on the origin and evolution of life, the exploration of Mars (anticipating the discovery of methane on Mars), and cheap access to space. He has a Ph.D. in physics from the University of Illinois at Urbana-Champaign and a B.S. in physics from the California Institute of Technology (Caltech).

[Python] How to combine two column vectors into a single column vector

How to combine two column vectors into a single column vector in Python and NumPy

Use the NumPy vstack(…) function as show below:

import numpy as np
one = np.array([[1], [2]])
two = np.array([[3], [4]])
blatz = np.vstack((one, two))
print(blatz)
[[1]
[2]
[3]
[4]] 
How to combine two column vectors into a single column vector in Python and NumPy using vstack

(C) 2022 by John F. McGowan, Ph.D.

About Me

John F. McGowan, Ph.D. solves problems using mathematics and mathematical software, including developing gesture recognition for touch devices, video compression and speech recognition technologies. He has extensive experience developing software in C, C++, MATLAB, Python, Visual Basic and many other programming languages. He has been a Visiting Scholar at HP Labs developing computer vision algorithms and software for mobile devices. He has worked as a contractor at NASA Ames Research Center involved in the research and development of image and video processing algorithms and technology. He has published articles on the origin and evolution of life, the exploration of Mars (anticipating the discovery of methane on Mars), and cheap access to space. He has a Ph.D. in physics from the University of Illinois at Urbana-Champaign and a B.S. in physics from the California Institute of Technology (Caltech).

The Python enumerate() Function and Dictionaries


The enumerate() function in Python loops over a tuple, list, or other container object returning a counter/index and value for each element of the object. For example:

pets = ('dog', 'cat', 'parrot', 'hamster', 'mongoose')
for index, pet in enumerate(pets):
print(index, pet)

produces:

0 dog
1 cat
2 parrot
3 hamster
4 mongoose

The enumerate() function defaults to starting the index or counter at zero. There is an optional start argument to start the index or counter at another value. For example:

for index, pet in enumerate(pets, 100):
print(index, pet)

produces:

100 dog
101 cat
102 parrot
103 hamster
104 mongoose

The enumerate() function is a built-in replacement for using a manual index or counter, the common practice in C-style languages such as C, C++, and Java. For example:

index = 0  # manual index
for pet in pets:
print(index, pet)
index += 1

which also produces:

0 dog
1 cat
2 parrot
3 hamster
4 mongoose

A manual index or counter is error-prone, often resulting in off-by-one or other errors. Using the enumerate() function instead of a manual index is generally considered the “Pythonic” way to generate a counter or index during a loop over a tuple, list or other container.

The Python programming language community uses “Pythonic” in a non-standard English way that may mean:

“cool” as in James Dean was cool

“Exploiting the features of the Python language to produce code that is clear, concise, and maintainable.” https://stackoverflow.com/questions/25011078/what-does-pythonic-mean

Many other definitions of Pythonic exist.

Pythonic is also a rarely used adjective in standard English meaning:

(1) of or relating to pythons (the snake)

(2) similar to a python; pythonlike

(3) gigantic or monstrous

enumerate() and Dictionaries

Like most modern programming languages, Python has a built-in dictionary type, also known as an associative array or hash table in other languages. Technically, a hash table is a method to implement a dictionary/associative array, but is often used as a synonym for a dictionary or associative array.

In Python, dictionaries take a key, an object, and return an associated value object. Very often the key and value are strings, but they need not be. For example, this dictionary enables one to look up the type of pet from the pet’s name:

pets_dict = { "Toby" : "dog", "Serena" : "cat", "Ted" : "hamster", "Wilma" : "parrot", "Riki-tiki-tavi" : "mongoose" }

By default, the for loop in Python loops over the keys in the dictionary. For example:

for key in pets_dict:
print(key)

produces:

Toby
Serena
Ted
Wilma
Riki-tiki-tavi

on my computer. The order of the keys is not guaranteed.

for key in pets_dict:
print(key, "is a", pets_dict[key])

produces:

Toby is a dog
Serena is a cat
Ted is a hamster
Wilma is a parrot
Riki-tiki-tavi is a mongoose

pets_dict.keys() returns a dict_keys container with the list of keys in the dictionary.

pets_dict.values() returns a dict_values container with the list of values in the dictionary.

pets_dict.items() returns a dict_items container with the list of (key, value) tuples in the dictionary.

What does enumerate() do when applied to a dictionary?

By default, Python enumerate() is applied to the keys in the dictionary. Remember the for loop in Python defaults to looping over the keys of a dictionary. For example:

for index, value in enumerate(pets_dict):
print(index, value)

produces:

0 Toby
1 Serena
2 Ted
3 Wilma
4 Riki-tiki-tavi

Toby, Serena, and so on are the keys of the dictionary, the names of the pets in the example.

In some cases, you may need an index into the list of tuples of items in the dictionary:

for index, item in enumerate(pets_dict.items()):
print(index, item)

produces:

0 ('Toby', 'dog')
1 ('Serena', 'cat')
2 ('Ted', 'hamster')
3 ('Wilma', 'parrot')
4 ('Riki-tiki-tavi', 'mongoose')

(C) 2019 by John F. McGowan, Ph.D.

About Me

John F. McGowan, Ph.D. solves problems using mathematics and mathematical software, including developing gesture recognition for touch devices, video compression and speech recognition technologies. He has extensive experience developing software in C, C++, MATLAB, Python, Visual Basic and many other programming languages. He has been a Visiting Scholar at HP Labs developing computer vision algorithms and software for mobile devices. He has worked as a contractor at NASA Ames Research Center involved in the research and development of image and video processing algorithms and technology. He has published articles on the origin and evolution of life, the exploration of Mars (anticipating the discovery of methane on Mars), and cheap access to space. He has a Ph.D. in physics from the University of Illinois at Urbana-Champaign and a B.S. in physics from the California Institute of Technology (Caltech).