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
library(shiny) | |
# Define server logic for random distribution application | |
shinyServer(function(input, output) { | |
# Reactive expression to generate the requested distribution. This is | |
# called whenever the inputs change. The renderers defined | |
# below then all use the value computed from this expression | |
data <- reactive({ | |
dist <- switch(input$dist, |
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
expected.x <- function(d, a, h) { | |
sum(sapply(0:h, function(y) prob.justy(d, a, h, y)) * 0:h) | |
} | |
prob.xormore <- function(d, a, h, x) { | |
if (d >= h && min(a, h) >= x) | |
sum(prob.justy.nocheck(d, a, h, x:min(a, h))) | |
else { | |
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
initial.mandel <- function(input) { | |
x <- seq(input$xmin, input$xmax, length.out=input$xresol) | |
y <- seq(input$ymin, input$ymax, length.out=input$yresol) | |
outer(x, y, function(x, y) complex(real=x, imaginary=y)) | |
} | |
calc.mandel <- function(c) { | |
z <- list(c) # z_1 = c の計算(?) | |
for (i in 1:input$niter) { | |
z[[i+1]] <- z[[i]]^2 + c # z_{i+1} = z_i^2 + c の計算 |
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
def adj_iter(network, x): | |
u"""network のノード x に隣接するエッジのイテレータを返す。 | |
素の edges_iter は存在しないノードに対してエラーを吐き面倒なので | |
このジェネレータ関数で回避する。 | |
""" | |
if network.has_node(x): | |
for t in network.edges_iter(x): | |
yield t | |
else: |
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
# -*- coding: utf-8 -*- | |
def main(): | |
(options, args) = parse_options() | |
def parse_options(): | |
import optparse | |
parser = optparse.OptionParser() |
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
# -*- coding: utf-8 -*- | |
import csv | |
import numpy as np | |
def cbind(*dfseq): | |
u"""行数が同じである複数のデータフレームを渡された順番に結合した | |
1つのデータフレームにして返す。 | |
""" |