Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 pymc3 as pm | |
import numpy as np | |
import arviz as az | |
%config InlineBackend.figure_format = 'retina' | |
# Data from https://twitter.com/tomstafford/status/1456914037195907079?s=20 | |
N = np.array([1258, 280]) # total number of caffiene and non-caffiene drinkers | |
k = np.array([966, 168]) # total number of those who have favourite mugs | |
def cohens_h(p): |
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
% Add tooolbox code to path | |
addpath('~/git-local/darc-experiments-matlab') | |
% Run the toolbox setup code | |
env_setup | |
% Get participant information with GUI | |
[expt_options] = getHumanExperimentOptions(); | |
plotting_style = 'full'; |
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
% Add tooolbox code to path | |
addpath('~/git-local/darc-experiments-matlab') | |
% Run the toolbox setup code | |
env_setup | |
% Get participant information with GUI | |
[expt_options] = getHumanExperimentOptions(); | |
plotting_style = 'full'; |
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
# We have a dataframe with many columns. | |
# 15 of these columns correspond to responses to questions about hunger. | |
# They group into 5 subscales (each with 3 questions). | |
# I want to calculate these subscales (means) as well as an overall score (mean of all). | |
# This then needs to applied to the control condition (C) and a fasted condition (F) scores | |
# Once the means are calculated I no longer need the raw scores, so bonus is to automatically remove these columns. Need to retain all other columns in orginal dataframe. | |
# The code below works just fine, but seems pretty verbose. Is there a more R-like, concise way to do this? | |
# It seems like a split-apply-combine, but applied to columns rather than rows? |
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
true_mean = 0; | |
true_sigma = 1; | |
% likelihood_func = @(x, mean, sigma) normpdf(x, mean, sigma); | |
% the above function to calcalate in matrix form, for speed | |
likelihood_func = @(params)... | |
prod(normpdf(repmat(x,[1 numel(params(1))]),... | |
repmat(params(1), [1 numel(x)])',... | |
repmat(params(2),[1 numel(x)])' ), 1); | |
%% generate data |
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
true_mean = 0; | |
true_sigma = 1; | |
% likelihood_func = @(x, mean, sigma) normpdf(x, mean, sigma); | |
% the above function to calcalate in matrix form, for speed | |
likelihood_func = @(x, mean, sigma)... | |
prod(normpdf(repmat(x,[1 numel(mean)]),... | |
repmat(mean, [1 numel(x)])',... | |
repmat(sigma,[1 numel(x)])' ), 1); | |
%% generate data |
NewerOlder