View option_pricing.cpp
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
// Call option Monte Carlo evaluation | |
#include <iostream> | |
#include <random> | |
#include <math.h> | |
#include <chrono> | |
using namespace std; | |
/* double stoc_walk: returns simulated price after periods |
View Random_forest_example.py
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
from sklearn.ensemble import RandomForestClassifier | |
from sklearn.cross_validation import train_test_split | |
import pandas as pd | |
import os | |
# Loading data | |
data = pd.read_csv('data.csv') | |
# Encoding categorical features into numerical | |
buying_map = {'vhigh':4,'high':3,'med':2,'low':1} |
View Arduino_measurement_sketch.ino
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
//Initialize global variables | |
int ledRed = 8; //Red LED pin | |
int ledGreen = 9; //Green LED pin | |
int sensorCurrent = 10; //Sensor pin | |
int sensorRed = 0; //Red laser light sensor | |
int sensorGreen = 0; //Green laser light sensor | |
int measurements = 0; //Number of measurements done | |
int numberOfMeasurements = 1; //Measurements to be done (must be the same as nSamples in the Python script) | |
float t1; //Initial time (time at the start of the measurement) | |
float t2; //End time (time at the end of the measurement) |
View python_measuring_function.py
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
#------------------------------------------------------------------------------ | |
# Measuring function. Makes nSamples measurements through an Arduino object | |
# Notes: | |
# The program loops until it collects the nSamples readings | |
# | |
# This function accepts an object of the Arduino class | |
def measure(nSamples,arduino,save=False): | |
try: |
View gathering_data.R
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
#------------------------------------------------------------------------------- | |
# Gathering the data | |
#------------------------------------------------------------------------------- | |
# Loading the entire mtcars dataset | |
data(mtcars) | |
# Subsetting the dataset for our use | |
dat <- subset(mtcars,select=c(mpg,disp,hp,drat,wt)) | |
dat |
View linear_reg.R
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
#------------------------------------------------------------------------------- | |
# Linear regression y = a + bx | |
#------------------------------------------------------------------------------- | |
# Fit the model | |
model1 <- lm(wt ~ disp) | |
# Parameters and information about the model | |
model1 | |
coef(model1) |
View Linear_model.R
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
#------------------------------------------------------------------------------- | |
# Another linear model using more information y = a*x1 + b*x2 + c*x3 + d*x4 | |
#------------------------------------------------------------------------------- | |
# Plot data | |
plot(disp,wt,type='p',xlab='Disp',ylab='Wt',main='Linear regression') | |
# Add a legend | |
legend("topleft",c("Observ.","Predicted"), col=c("black","red"), lwd=3) |
View waveEquation.py
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 numpy as np | |
from numpy import pi | |
import matplotlib.pyplot as plt | |
import matplotlib.animation as animation | |
plt.style.use('dark_background') | |
fig = plt.figure() | |
fig.set_dpi(100) | |
ax1 = fig.add_subplot(1,1,1) |
View RC.py
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 numpy as np | |
import matplotlib.pyplot as plt | |
plt.style.use('ggplot') | |
c = 100 * 10**(-6) | |
v = 5 | |
r = 2000 | |
t = np.linspace(0,1,1000) |
View transportEq.py
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
#Transport equation with decay implementation | |
import numpy as np | |
from numpy import pi | |
import matplotlib.pyplot as plt | |
import matplotlib.animation as animation | |
fig = plt.figure() | |
fig.set_dpi(100) | |
ax1 = fig.add_subplot(1,1,1) |
OlderNewer