Skip to content

Instantly share code, notes, and snippets.

View suryadutta's full-sized avatar

Surya Dutta suryadutta

View GitHub Profile
@suryadutta
suryadutta / runjising.m
Created March 31, 2017 15:25
RunJising Binning
for k=1:kmax
% Run simulation
[Msamp, Esamp, spin] = jisingAnnealing(N, T(k), num_steps, num_burnin,...
flip_prop, J, B);
binSize = 100;
totalUsed= floor(length(Esamp(num_burnin:end)) / binSize);
cv_binning = zeros(1,totalUsed); %initialize CV
chi_binning = zeros(1,totalUsed); %initialize chi
D = csvread('data.dat',5,0);
tempSteps = D(:,1);
tempFactor = 2./tempSteps;
fout = fopen(['energyout.csv'], 'w');
fprintf(fout, ['Temperature, k, K(k), Energy\n']);
k = 2.*(sinh(tempFactor))./((cosh(tempFactor)).^2);
anonymous {
id: 2,
title: 'BLUE_EXPONENTIALFUNCTIONS.',
title_blue: 'Exponential\t\n',
title_yellow: 'Functions\n',
background_location: '/images/moduleBackgrounds/Connecticut_Module.png',
background_name: 'Connecticut Hall\n',
background_desc: '<p>Completed in 1752, Connecticut Hall is Yale’s oldest standing building. A student dormitory for over 200 years, it was designated a National Historic Landmark in 1965.</p>\n',
overview: '<p class="text_margin"><p>Grow, Grow Grow, Go, Go, Go! Exponential functions are great for describing things that grow rapidly. We\'re going to examine how Ben Franklin\'s gift to the cities of Philadelphia and Boston grew over time to get an understanding of exponential functions. We conclude by looking at Malthus\' theories of population growth. Questions we will interact with:</p>\n<ul>\n<li>What\'s an exponential function? (Ok, this seems kind of basic. But it\'s necessary)</li>\n<li>How can we distinguish between an exponential function and a linear function?<
#include "MOptimumFilter.hh"
#include "QEvent.hh"
#include "QEventList.hh"
#include "QRawEvent.hh"
#include "QBaseModule.hh"
#include "QSampleInfo.hh"
#include "QRunDataHandle.hh"
#include "QBaseType.hh"
#include "QBaselineData.hh"
#include "QAveragePulseHandle.hh"
@suryadutta
suryadutta / QOptimumFilter.cc
Created August 3, 2017 20:50
Implementation of Optimum Filter
#include "QOptimumFilter.hh"
#include "QError.hh"
#include "QMatrix.hh"
#include "QRealComplexFFT.hh"
#include "QFir.hh"
#include <sstream>
// EXTRA_JITTERS:
// 1: minimum number needed for interpolation
// 2: more point to see if we have a minimum at the boundary (enable nice parabola)
@suryadutta
suryadutta / OptimumFilter.cc
Created August 3, 2017 20:52
New Implementation of Optimum Filter
#include "OptimumFilter.hh"
#include "QRealComplexFFT.hh"
#include <iostream>
#include "QMatrix.hh"
using namespace std;
using namespace Cuore;
OptimumFilter::OptimumFilter(): nSigPulses(0),nNoisePS(0){
//par0=par1=par2=1;
@suryadutta
suryadutta / OptimumFilter.cc
Created August 3, 2017 20:52
New Implementation of Optimum Filter
#include "OptimumFilter.hh"
#include "QRealComplexFFT.hh"
#include <iostream>
#include "QMatrix.hh"
using namespace std;
using namespace Cuore;
OptimumFilter::OptimumFilter(): nSigPulses(0),nNoisePS(0){
//par0=par1=par2=1;
@suryadutta
suryadutta / logtocsv.py
Last active September 24, 2017 10:25
txt to csv parser
import csv
#get hci output with bash command: hcidump -r hci.log -t > hci.txt
logs = open('hci.txt','r').read().replace('\n',' ').replace('586524','\n2017')
logs_output = open("hcidata.txt", "w")
logs_output.write(logs)
logs_output.close()
data = open('hcidata.txt','r') #replace with hci output
csv_data = []
skip_header = True
for line in data:
@suryadutta
suryadutta / vocab_extract.r
Last active November 13, 2017 02:20
Extract 10,000 useful words from CSV
#install.packages('tm')
library(tm)
#install.packages('slam')
library("slam")
#import data
alldata <- read.csv('stackexchange/20161215StatsPostsMerged.csv', header = TRUE, stringsAsFactors = FALSE)
#make corpus
@suryadutta
suryadutta / reduceDTM.r
Created November 14, 2017 03:23
reduce size of DTM to make computation faster
reduceDTM <- function(dtm){
term_tfidf <-
tapply(dtm$v/row_sums(dtm)[dtm$i], dtm$j, mean) *
log2(nDocs(dtm)/col_sums(dtm > 0))
dtm <- dtm[,term_tfidf >= median(term_tfidf)]
dtm <- dtm[row_sums(dtm) > 0,]
return(dtm)
}