This file contains hidden or 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
library(phom) | |
library(scatterplot3d) | |
N <- 20 | |
R <- 25 | |
r <- 10 | |
sd <- 1 | |
ts <- seq(0,2*pi,pi/N) | |
ps <- seq(0,2*pi,pi/N) |
This file contains hidden or 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
### Restricted Boltzmann Machine implementation by isobe | |
sigmoid <- function(x) 1/(1+exp(-x)) | |
rbm <- function(obs,n_hidden,eta=0.05, | |
epsilon=0.05,maxiter=100, | |
CD_k=1,reconstruct_trial=10, | |
verbose=0) { | |
L <- nrow(obs) | |
N <- ncol(obs) |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
from mpl_toolkits.mplot3d import Axes3D | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from scipy import optimize | |
def f(x,y): | |
r1 = np.sqrt(x**2+y**2) | |
r2 = np.sqrt((x-15)**2+(y-15)**2) | |
return np.sin(r1)/np.sqrt(r1) + 1.5*np.exp(-r2) |
This file contains hidden or 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
## particle filter implementation by isobe | |
particle_filter <- function(x0,y,f_noise,f_like,N,M=1) { | |
tmax <- nrow(y) | |
D <- length(x0) # == ncol(y) | |
do_noise <- function(x) { | |
x1 <- c() | |
for (i in 1:N) { | |
for (j in 1:M) { |
This file contains hidden or 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
ad1 | ad2 | ad3 | |
---|---|---|---|
1000 | 0 | 0 | |
1000 | 0 | 0 | |
1000 | 0 | 0 | |
1000 | 0 | 0 | |
1000 | 0 | 0 | |
0 | 0 | 1000 | |
0 | 0 | 1000 | |
0 | 0 | 1000 | |
0 | 0 | 1000 |
This file contains hidden or 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
N <- 3000 | |
pt <- proc.time() | |
m <- matrix(runif(N*N), nrow=N, ncol=N) | |
ans <- sum(diag(m %*% solve(m))) | |
pt <- proc.time()-pt | |
print(paste("ans =",ans)) | |
print(paste("time = ",pt[3])) |
This file contains hidden or 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
library(R2WinBUGS) | |
library(coda) | |
data <- list( | |
x=c(1.0,1.5,1.5,1.5,2.5,4.0,5.0,5.0,7.0,8.0, | |
8.5,9.0,9.5,9.5,10.0,12.0,12.0,13.0,13.0,14.5, | |
15.5,15.5,16.5,17.0,22.5,29.0,31.5), | |
y=c(1.80, | |
1.85,1.87,1.77,2.02,2.27,2.15,2.26,2.47,2.19, | |
2.26,2.40,2.39,2.41,2.50,2.32,2.32,2.43,2.47, |
This file contains hidden or 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
#light | |
module Crawl | |
open System | |
open Abot.Crawler | |
open Abot.Poco | |
let Fetch (url: string) = |
This file contains hidden or 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
#light | |
let checkio (text:string,words:string) = | |
let lt = text.ToLower() | |
let lw = words.ToLower() | |
let range = [0..text.Length-1] | |
let index w = | |
(fun i -> lt.Substring(i).StartsWith(w)) | |
|> List.filter <| range | |
|> List.map (fun i -> (i,i+w.Length)) |
This file contains hidden or 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
(ns checkio.words-finder | |
(:use [clojure.string :only [split]] | |
[clojure.set :only [intersection]])) | |
(defn- checkio [text, words] | |
(let [lt (.toLowerCase text) | |
r (-> text .length range) | |
index (fn [w] | |
(filter #(.. lt (substring (first %)) (startsWith w)) | |
(map vector r (iterate inc (.length w))))) |