forked from mbostock's block: OMG Particles!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Compositional PCA" | |
--- | |
## Problem | |
From [https://sciencemastodon.com/\@Alex_Koiter/109909545205270622](https://sciencemastodon.com/@Alex_Koiter/109909545205270622), "Question for the [#soil](https://fosstodon.org/tags/soil) and [#stats](https://fosstodon.org/tags/stats) peeps. Can you include the percent sand, silt, and clay in to a PCA? The reason I am asking is that the three variables always sum to 100% My lurking on stack exchange etc seems to suggest that it is ok, but some how it doesn't feel right." | |
Let's check this for three variables. We don't have a proof but suspect different eigenvalues to $X^TX$ . Let's try to shoot for a negative case. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
as_tribble_string <- function(df, delim = "|") { | |
headers <- df |> | |
names() |> | |
purrr::map(as.name) |> | |
paste0(a = "~", b = _, collapse = ", ") | |
# write contents to read back | |
output_file <- tempfile() | |
readr::write_delim( | |
df, | |
file = output_file, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Generate random numbers from an \eqn{a}-telescoping | |
#' discrete distribution | |
#' | |
#' Let \eqn{a(n)} be a sequence (a function defined on the | |
#' natural numbers) that is non-decreasing and such that | |
#' \eqn{a(0)=1}. Then the a-telescoping discrete | |
#' distribution has a probability mass function (PMF) given | |
#' by | |
#' | |
#' \deqn{p(n) = \frac{1}{a(n)} - \frac{1}{a(n+1)}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle | |
def draw_list(tortuga, ns, step = 30, angle = 90): | |
tortuga.home() | |
while True: | |
for n in ns: | |
tortuga.forward(n * step) | |
tortuga.right(angle) | |
if tortuga.position() == (0, 0): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(purrr) | |
library(rlang) | |
# "closure"s work for .f in map() | |
print(typeof(seq)) | |
print(map(c(1L, 3L), seq, to = 5L, by = 1L)) | |
# "builtin"s do not work for .f in map() | |
print(typeof(seq.int)) | |
# Generates an error: | |
# Error in .f(.x[[i]], ...) : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IF [Que21 Primary Language Spoken A 2034] = "8" THEN // Other | |
IIF(ISNULL([Que22 Other 2035]), "Missing", "Completed") | |
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Pixel Programmer</title> | |
</head> | |
<body> | |
<div> | |
<div id="pixel"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: (function(e, a, g, h, f, c, b, d) { | |
if (!(f = e.jQuery) || g > f.fn.jquery || h(f)) { | |
c = a.createElement("script"); | |
c.type = "text/javascript"; | |
c.src = "http://ajax.googleapis.com/ajax/libs/jquery/" + g + "/jquery.min.js"; | |
c.onload = c.onreadystatechange = function() { | |
if (!b && (!(d = this.readyState) || d == "loaded" || d == "complete")) { | |
h((f = e.jQuery).noConflict(1), b = 1); | |
f(c).remove() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Markov Chain Fun</title> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> | |
<!--[if lt IE 9]> | |
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
<style type="text/css"> |
NewerOlder