Skip to content

Instantly share code, notes, and snippets.

View mark-andrews's full-sized avatar

Mark Andrews mark-andrews

View GitHub Profile
From ef640acaf0a62d332040f2dc7a6247839eb4f664 Mon Sep 17 00:00:00 2001
From: Mark Andrews <[email protected]>
Date: Mon, 25 Oct 2021 20:03:04 +0100
Subject: [PATCH] Updating dependencies in PKGBUILD
* Add the quarto dependencies
* Change _nodever to 14.17.5
---
PKGBUILD | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
set.seed(10101) # Omit or change this if you like
N <- 25
x_1 <- rnorm(N)
x_2 <- rnorm(N)
beta_0 <- 1.25
beta_1 <- 1.75
beta_2 <- 2.25
Sleep,Stress
3.1,36
4.4,33
3.3,33
3.6,37
3,32
3.3,30
3.7,35
4.1,47
4.7,30
batch m n
1 0 20
2 0 20
3 0 20
4 0 20
5 0 20
6 0 20
7 0 20
8 0 19
9 0 19
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = nn.Conv2d(1, 10, kernel_size=5)
self.conv2 = nn.Conv2d(10, 20, kernel_size=5)
self.conv2_drop = nn.Dropout2d()
self.fc1 = nn.Linear(320, 50)
self.fc2 = nn.Linear(50, 10)
def forward(self, x):
import torch
import torchvision
tt = torchvision.transforms.Compose([torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize((0.1307,), (0.3081,))])
mnist_train = torchvision.datasets.MNIST('./files/', train=True, download=True, transform=tt)
mnist_test = torchvision.datasets.MNIST('./files/', train=False, download=True, transform=tt)
# View the dummy code of a categorical variable
# assumes package fastDummies is installed
# assumes tidyverse is installed
# Usage:
get_dummy_code <- function(Df, variable){
tmp_df <- fastDummies::dummy_cols(Df, remove_first_dummy = TRUE)
tmp_df <- dplyr::select(tmp_df, dplyr::starts_with(variable))
dplyr::arrange(dplyr::distinct(tmp_df), !!variable)
}
library(tidyverse)
theme_set(theme_classic())
plot_normal <- function(mean = 0, sd = 1, xmin = -3, xmax = 3) {
tibble(x = seq(xmin, xmax, length.out = 1000),
d = dnorm(x, mean = mean, sd = sd)) %>%
ggplot(aes(x = x, y = d)) + geom_line() +
geom_segment(x = mean,
xend = mean,
y = 0,
# This is a set of functions etc to illustrate the concept of a sampling
# distribution using the example of sampling gold and silver coins
# from a box.
library(tidyverse)
# set random number generator seed
set.seed(10101)
make_box <- function(N = 100, g = 0.5){
stimuli <- letters[1:9]
n = 2
K <- 36
stimuli_list <- vector(mode = "list", length = K)
response_list <- vector(mode = "list", length = K)
for (i in seq(K)){
if (i <= n){