liyiresearch / bnp_tutorial Goto Github PK
View Code? Open in Web Editor NEWThis project forked from tbroderick/bnp_tutorial
This project forked from tbroderick/bnp_tutorial
To recreate the examples from the tutorial, open R and run the following commands at the R prompt. ============================================== ==== Tutorial Part I ============================================== Load the functions for Example 1: > source("ex1_beta.R") Draw a random distribution using a beta random variable with parameters (1,1). Keep pressing enter to get more iid beta random variables. Press "x" and then enter when you're done. > ex1_draw_betas(1) Choose a very small parameter tuple > ex1_draw_betas(0.01) Choose a very large parameter tuple > ex1_draw_betas(1000) Note: though we didn't cover it in the tutorial, you can use the function "ex1_draw_betas_diffa" to draw random distributions using both beta parameters. e.g. > ex1_draw_betas_diffa(0.1,10) Load the functions for Example 2. Note: you may need to install the MCMCpack package first: > install.packages("MCMCpack") > source("ex2_diri.R") Draw a random distribution using a Dirichlet random variable with all parameters 1. Keep pressing enter to get more iid Dirichlet random variables. Press "x" and then enter when you're done. > ex2_draw_diris(K=4,a_scalar=1) Choose a very small shared parameter > ex2_draw_diris(K=4,a_scalar=0.01) Choose a very large shared parameter > ex2_draw_diris(K=4,a_scalar=1000) Note: though we didn't cover it in the tutorial, you can use the function "ex2_draw_diris_diffa" to draw random distributions using different Dirichlet parameters. e.g. > ex2_draw_diris_diffa(c(1,3,5,2)) Load Example 3 Draw a Dirichlet distribution with large K. > source("ex3_largeK_distr.R") Press enter to keep making draws from the random distribution. Press "x" and then enter when you're done. Note: in the tutorial we tried out different values of a. (For K=1000, we tried a=0.001,0.01,1,10.) Although we didn't cover it in the tutorial, you can use the function "ex3_gen_largeK_diri" to also try out different values of K. E.g. > ex3_gen_largeK_diri(K=1000,a=0.01) Load Example 4 Look at the cluster assignments according to a Dirichlet distribution with large K. > source("ex4_largeK_count.R") Press enter to keep making draws from the random distribution. Press "x" and then enter when you're done. Note: though we didn't cover it in the tutorial, you can use the function "ex4_gen_largeK_count" to draw cluster assignments with different values of K and a. E.g. > ex4_gen_largeK_count(K=1000,a=0.01) ============================================== ==== Tutorial Part II ============================================== Load the functions for Example 5: > source("ex5_gem.R") Draw a random distribution with GEM parameter alpha. We tried alpha=1,10,100. E.g. > ex5_draw_gem(alpha=10) Load Example 6 > source("ex6_dpmm.R") Press enter to keep making draws from the DPMM. Enter a number to make a larger number of draws at once. Press "x" and then enter when you're done. ============================================== ==== Tutorial Part III ============================================== Load Example 7 Draw a random, simulated data set. Run a Gibbs sampler for a CRP Gaussian mixture model with all data points initialized to the same cluster. > source("ex7_sampler.R") Press enter to keep making Gibbs samples. Enter a number to go that many full iterations forward in the sampler. Press "x" and then enter when you're done. Run a Gibbs sampler for a CRP Gaussian mixture model with all data points initialized to their own cluster. > ex7_crp_gibbs(data=data$x, sd=1, initz=1:nrow(data$x)) Note: though we didn't cover it in the tutorial, you can generate a new data set, possibly with a different data set size or with different cluster widths, with the function "ex7_gen_data". e.g. > data = ex7_gen_data(Ndata=1000,sd=0.3)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.