Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
// This code is based on matlab code provided through the course "Monte Carlo Methods in Finance". | |
// https://iversity.org/my/courses/monte-carlo-methods-in-finance/ | |
// and Olaf Smits's Python conversion | |
// http://nbviewer.ipython.org/github/olafSmits/MonteCarloMethodsInFinance/blob/master/Week%201.ipynb?create=1 | |
open System | |
open Deedle | |
open FSharp.Charting | |
let readFrame (stock:string) = |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
--- | |
name: ggplotly | |
layout: post | |
title: Make your ggplots shareable, collaborative, and with D3 | |
date: 2014-04-17 | |
author: Matt Sundquist | |
authorurl: https://plot.ly/team | |
tags: | |
- R | |
- API |
#include <iostream> | |
#include <algorithm> | |
#include <vector> | |
using namespace std; | |
int main() | |
{ | |
// The user would introduce different values for divisor | |
int divisor = 3; | |
vector<int> numbers { 1, 2, 3, 4, 5, 10, 15, 20, 25, 35, 45, 50 }; |
// Here's my data model | |
function ViewModel(first, last) { | |
this.firstName = ko.observable(first); | |
this.lastName = ko.observable(last); | |
this.fullName = ko.computed(function() { | |
// Knockout tracks dependencies automatically. It knows that fullName depends on firstName and lastName, because these get called when evaluating fullName. | |
return this.firstName() + " " + this.lastName(); | |
}, this); | |
}; |
// Here's my data model | |
function ViewModel() { | |
//this.firstName = ko.observable(first); | |
//this.lastName = ko.observable(last); | |
this.firstName = "first"; | |
/* | |
this.fullName = ko.computed(function() { | |
// Knockout tracks dependencies automatically. It knows that fullName depends on firstName and lastName, because these get called when evaluating fullName. | |
return this.firstName() + " " + this.lastName(); | |
}, this); |
# load the package and data set "Teams" | |
install.packages("Lahman") | |
library("Lahman") | |
data(Teams) | |
# | |
# | |
# CREATE LEAGUE SUMMARY TABLES | |
# ============================ | |
# | |
# select a sub-set of teams from 1901 [the establishment of the American League] forward to 2012 |
PIMCO Quantitative Research
Steve Sapra, Ph.D., CFA and Manny Hunjan, CFA
October 2013
import sys | |
import json | |
def hw(): | |
print 'Hello, world!' | |
def lines(fp): | |
print str(len(fp.readlines())) | |
def main(): |
#include <iostream> | |
#include <chrono> | |
#include <random> | |
int main(int argc, char* argv []) | |
{ | |
auto x = 1; | |
std::cout << "auto variable x = " << x << std::endl; | |
srand(0u); |