Skip to content

Instantly share code, notes, and snippets.

@rpietro
rpietro / bayesian_comp_R_ch2.R
Created December 23, 2013 02:59
Comments on chapter 2 of bayesian computation with R
####################################
# Section 2.3 Using a Discrete Prior
####################################
install.packages('LearnBayes')
library(LearnBayes)
p = seq(0.05, 0.95, by = 0.1) # vector of proportion values
prior = c(1, 5.2, 8, 7.2, 4.6, 2.1, 0.7, 0.1, 0, 0)
prior = prior/sum(prior) # vector of prior probabilities
@rpietro
rpietro / bayesian_comp_R_ch1.R
Created December 23, 2013 02:58
Comments on chapter 1 of bayesian computation with R
# Section 1.2 R commands
# Section 1.2.2
if (!require('LearnBayes')) install.packages('LearnBayes')
data(studentdata)
studentdata[1:3,]
attach(studentdata)
# Section 1.2.3
@rpietro
rpietro / think_bayes_ch1.md
Created December 20, 2013 18:27
think bayes chapter 1 - http://goo.gl/Tvp6R

Think Bayes - Chapter 1

Deriving Bayes theorem

$p(A \land B) = p(B \land A)$
$p(A)*p(B|A) = p(B)*p(A|B)$
$p(B|A) = \frac{p(B)*p(A|B)}{p(A)}$

Cookie problem

  • bowl 1
@rpietro
rpietro / Preferences.sublime-settings
Created December 19, 2013 03:27
my sublime user preferences
{
"auto_complete": true,
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"dictionary": "Packages/Languages/en_US.dic",
"font_size": 13.0,
"ignored_packages":
[
"Vintage",
"WordCount",
"View In Browser"
@rpietro
rpietro / edx_insights.sh
Created December 18, 2013 09:08
experimenting with edx insights
## installation following http://goo.gl/5TXSdn
#install django if it's not already installed
pip install Django==1.6.1
python # make sure which version or versions you currently have installed
import django # just to test
# fork https://github.com/edx/insights
git clone https://github.com/rpietro/insights.git
@rpietro
rpietro / datajam.md
Created December 18, 2013 02:03
edx datajam image installed through virtualbox and vagrant

Sequence to play with edX datajam

getting into the virtual machine

cd ~/edx-datajam-root ./edx-datajam ssh #get into virtual machine

LMS workflow

sudo su edxapp # switch to the edxapp account

@rpietro
rpietro / requireinstall.sublime-snippet
Created December 17, 2013 06:50
combining require and install.packages in a single line for R
<snippet>
<content><![CDATA[
if (!require('${1:package}')) install.packages('${2:package}')
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>requireinstall</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
@rpietro
rpietro / singlechoice.sublime-snippet
Created December 15, 2013 22:50
xml snippet for single choice item in edx
<snippet>
<content><![CDATA[
<problem>
<startouttext/>
<p>
${1:stem}</p>
<endouttext/>
<choiceresponse>
<checkboxgroup>
@rpietro
rpietro / multiplechoice.sublime-snippet
Created December 15, 2013 22:37
xml snippet for multiple choice item in edx
<snippet>
<content><![CDATA[
<problem>
<p>
${1:stem}</p>
<multiplechoiceresponse>
<choicegroup type="MultipleChoice">
<choice correct="${2:true false}" name="${3:var1}">
<text>${4:option1}</text>
@rpietro
rpietro / bifactor_lavaan.R
Created December 15, 2013 04:41
bifactor model using lavaan
# script stolen and adapted from http://goo.gl/kUzaov
if (!require('lavaan')) install.packages('lavaan')
if (!require('Rcmdr')) install.packages('Rcmdr')
# creating a dataset for g + 3 factors, all orthogonal