[過去ログ] 臨床統計もおもしろいですよ、その1 [無断転載禁止]©2ch.net (747レス)
上下前次1-新
このスレッドは過去ログ倉庫に格納されています。
次スレ検索 歴削→次スレ 栞削→次スレ 過去ログメニュー
676: 2018/09/09(日)22:17 ID:+VpBquyc(1/2) AAS
k=20
pair=NULL
for(i in 1:k){
a=sort(rpois(2,7))
b=sort(rpois(2,7))
c=sum(a>b)
print(c(a=a,b=b,pair=c))
pair[i]=c
}
hist(pair)
省17
677: 2018/09/09(日)22:36 ID:+VpBquyc(2/2) AAS
# reverse' [] = []
# reverse' (x:xs) = reverse'(xs) ++ [x]
#
# main = do
# print $ reverse' [1..10]
reverse <- function(x){
if(!length(x)) return(NULL)
c(Recall(x[-1]),x[1])
}
cat(reverse(LETTERS[1:26]))
678: 2018/09/10(月)14:53 ID:40BngIEI(1/3) AAS
draft
rot13ch <- function(ch){
if('A' <= ch & ch <= 'M' ) LETTERS[which(x==LETTERS)+13]
if('a' <= ch & ch <= 'm' ) LETTERS[which(x==letters)+13]
if('N' <= ch & ch <= 'Z' ) LETTERS[which(x==LETTERS)-13]
if('n' <= ch & ch <= 'z' ) LETTERS[which(x==letters)-13]
else ch
}
rot13 <- function(x){
x=strsplit(x,NULL)
省8
679: 2018/09/10(月)15:06 ID:40BngIEI(2/3) AAS
draft2
rot13ch<- function(x){
if('A' <= x & x <= 'M' ) re=LETTERS[which(x==LETTERS)+13]
if('a' <= x & x <= 'm' ) re=letters[which(x==letters)+13]
if('N' <= x & x <= 'Z' ) re=LETTERS[which(x==LETTERS)-13]
if('n' <= x & x <= 'z' ) re=letters[which(x==letters)-13]
else re=x
return(re)
}
rot13ch('j')
省8
680: 2018/09/10(月)16:11 ID:40BngIEI(3/3) AAS
draft 3
rot13ch<- function(x){
if('A' <= x & x <= 'M' ) re=LETTERS[which(x==LETTERS)+13]
else
if('a' <= x & x <= 'm' ) re=letters[which(x==letters)+13]
else
if('N' <= x & x <= 'Z' ) re=LETTERS[which(x==LETTERS)-13]
else
if('n' <= x & x <= 'z' ) re=letters[which(x==letters)-13]
else re=x
省12
681: 2018/09/10(月)18:57 ID:V03Ln2wY(1) AAS
Gacha <- function(p){ # p: probability of each Gacha item
p=p/sum(p)
sum.rev <- function(x){ # i,j,k -> 1/(p[i]+p[j]+p[k])
n=length(x)
s=numeric(n)
for(i in 1:n) s[i]=p[x[i]]
1/sum(s)
}
n=length(p)
re=numeric(n)
省19
682: 2018/09/10(月)20:37 ID:YF8r2q2P(1) AAS
1万回のシミュレーション
> mean(replicate(1e4,sim(1:10)))
[1] 68.7788
理論値
> Gacha(1:10)
[1] 68.98458
683: 2018/09/11(火)13:14 ID:DPX9K4Dn(1/2) AAS
Gacha.fm <- function(p,write=FALSE){
n=length(p)
par=letters[1:n]
fm <- function(v){
nv=length(v)
re=character(nv)
for(j in 1:nv) re[j]=par[v[j]]
s=paste(re,collapse='+')
if(nv==1) paste0('1/',s)
else paste0('1/(',s,')')
省18
684: 2018/09/11(火)13:15 ID:DPX9K4Dn(2/2) AAS
Gacha.fm <- function(p,write=FALSE){
n=length(p)
par=letters[1:n]
fm <- function(v){
nv=length(v)
re=character(nv)
for(j in 1:nv) re[j]=par[v[j]]
s=paste(re,collapse='+')
if(nv==1) paste0('1/',s)
else paste0('1/(',s,')')
省18
685: 2018/09/12(水)17:03 ID:+rWfu75u(1/2) AAS
draft
insert <- function(x,yys){
if(!length(yys)) return x
else {
y=yy[1]
ys=yys[-1]
if(x<y) return c(x,y,ys)
else c(y, Recall(x,ys))
}
}
省8
686: 2018/09/12(水)17:41 ID:MBeBhzv/(1) AAS
insert <- function(x,y){
if(!length(y)) return(x)
if(x<y[1]) return(c(x,y))
return(c(y[1], Recall(x,y[-1])))
}
isort <- function(x){
if(!length(x)) return(NULL)
insert(x[1],Recall(x[-1]))
}
isort(c(4, 6, 9, 8, 3, 5, 1, 7, 2))
687: 2018/09/12(水)20:36 ID:+rWfu75u(2/2) AAS
bsort <- function(x){
if(!length(x)) return(NULL)
if(length(x)==1) return(x)
else{
y=bsort(x[-1])
ifelse(x[1]<y[1],c(x[1],y),c(y[1],bsort(c(x[1],y[-1])
}
}
bsort(c(3,1,4,1,5,9,2,6,5)
688: 2018/09/13(木)07:37 ID:ha3KPNlb(1/4) AAS
sim2 <- function(p){
n=length(p) # number of items
if(sum(p)>=1){ # no blank and/or rate of probabilities
prob=p/sum(p) # scaling for sum(prob)=1
lot=1:n # no blank lot
}else{
prob=c(p,1-sum(p)) # blank with probability of 1-sum(p)
lot=1:(n+1) # lot[n+1] blank lot
}
y=NULL
省8
689: 2018/09/13(木)08:15 ID:ha3KPNlb(2/4) AAS
p=c(9,9,9,9,9,5)/50
n=length(p)
seg=cumsum(p)
p
seg
x=runif(1)
x
x > seg
k=numeric(n)
k | (x > seg)
690: 2018/09/13(木)08:35 ID:ha3KPNlb(3/4) AAS
p=c(9,9,9,9,9,5)/50
n=length(p)
seg=cumsum(p)
count=0
k=numeric(n)
while(k<2^n-1){
x=runif(1)
k | (x > seg)
k=k | (x > seg)
count=count+1
省2
691: 2018/09/13(木)11:52 ID:vlGxfg9U(1) AAS
sim1 <- function(p){
n=length(p)
sep=cumsum(p)
y=NULL
count=0
while(length(y) < n){
z=sample(1:n,1,prob=p)
if(!any(z==y)) y=append(y,z) # append new item only
count=count+1
}
省17
692: 2018/09/13(木)19:14 ID:ha3KPNlb(4/4) AAS
qsort [] = []
qsort (n:xs) = qsort lt ++ [n] ++ qsort gteq
where
lt = [x | x <- xs, x < n]
gteq = [x | x <- xs, x >= n]
main = do print $ qsort [4, 6, 9, 8, 3, 5, 1, 7, 2]
693: 2018/09/14(金)07:47 ID:IOEu7JkF(1/2) AAS
foo <- function(a,b,c){
gr=expand.grid(1:a,1:b)
c2=(1:c)^2
f = function(x,y) (x<y) & (x^2+y^2) %in% c2
i=which(mapply(f,gr[,1],gr[,2]))
ab=as.matrix(gr[i,])
cbind(ab,sqrt(ab[,1]^2+ab[,2]^2))
}
foo(20,20,20)
a=20;b=20;c=20
省4
694: 2018/09/14(金)08:01 ID:IOEu7JkF(2/2) AAS
foo <- function(a,b,c){
gr=expand.grid(1:a,1:b)
c2=(1:c)^2
f = function(x,y) (x<y) & (x^2+y^2) %in% c2
i=which(mapply(f,gr[,1],gr[,2]))
ab=as.matrix(gr[i,])
cbind(ab,sqrt(ab[,1]^2+ab[,2]^2))
}
foo(20,20,20)
foo(100,100,100)
省9
695: 2018/09/14(金)09:51 ID:pDMF5zq8(1) AAS
#include<stdio.h>
#include<stdlib.h>
int pit(int A,int B, int C){
int a,b,c; int pit=0;
for(a=1;a<=A;a++){
for(b=a;b<=B;b++){
for(c=b;c<=C;c++){
if((a<b) && (a*a+b*b==c*c)) {
++pit;
printf("%d : %d * %d + %d * %d = %d * %d\n",pit,a,a,b,b,c,c);
省14
上下前次1-新書関写板覧索設栞歴
あと 52 レスあります
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル
ぬこの手 ぬこTOP 0.108s*