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
x=zeros(Float64,5) | |
maxmultiple=1000 | |
for m=1:maxmultiple | |
x[5]=4*5*m #It has to be divisalbe by 4 and 5 | |
for i=4:-1:1 | |
x[i]=5x[i+1]/4+1 | |
end | |
x0=x[1]*5/4+1 | |
if isinteger(x)&&isinteger(x0) | |
println(int(x)) |
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
function pairs(d::DataFrame) | |
varnames= map(string,names(d)) | |
l=length(varnames) | |
count=0 | |
for i=1:l | |
for j=1:l | |
count+=1 | |
ax=subplot(l,l,count) | |
ax[:xaxis][:set_visible](false) | |
ax[:yaxis][:set_visible](false) |
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
function dataframeplot(d::DataFrame,facsym,idsym) | |
factors=sort(unique(d[facsym])) #We need this to do the boxpols | |
numpoints=size(d,1) | |
numfactors=length(factors) | |
data=Array(Array{Float64},numfactors) | |
for i=1:numfactors data[i]=[] end | |
for i=1:numpoints | |
idvar=d[idsym][i] | |
fac=d[facsym][i] | |
for j=1:numfactors |
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
function backgammon_prob() | |
location_hits=zeros(Int,24) | |
for i=1:6, j=1:6 | |
if(i!=j) # to avoid double counting doubles | |
location_hits[i]+=1 | |
location_hits[j]+=1 | |
else | |
location_hits[j]+=1 | |
end | |
location_hits[i+j]+=1 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# This script fixes subtitle timing your timestamps | |
# from on file to adjust another | |
# Opening up the first file in swedish | |
using StringEncodings | |
open("The.Seventh.Seal.1957.PROPER.1080p.BluRay.x264-SADPANDA.srt") do io | |
global swe=readall(io,enc"ISO-8859-15") | |
end; | |
swesplit=matchall(r"(\d{1,4}\r\n\d.*?)(?=(\n\d|$))"s,swe); | |
# The second file in English | |
open("The\ Seventh\ Seal\ [Det\ Sjunde\ Inseglet].1957.BRRip.XviD.AC3-VLiS.srt") do io |
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 random | |
def pm(x): | |
if x>0: | |
return "+" | |
else: | |
return "" | |
def int_prob_gen(n): | |
s=0 |
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
function int_prob_gen(n) | |
starting_time=time() | |
s=0 #successes | |
pm(x)=x>0? "+":"" | |
for i=1:n | |
x=rand(-10:10) | |
y=rand(-10:10) | |
op=rand(["+","-"]) | |
right_ans="($x)$op($y)"|>parse|>eval | |
parse_correct=false |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
parksim <-function(nreps) { | |
nvals<-rgeom(nreps,0.15)+1 | |
dvals<-ifelse(nvals<=10,11-nvals,nvals-11) | |
mean(dvals) | |
} | |
system.time(parksim(100000000)) |
OlderNewer