2018年12月10日 星期一

R command

clear console

https://stackoverflow.com/questions/14260340/function-to-clear-the-console-in-r-and-rstudio

CTL+L

clc <- function() cat(rep("\n", 50))
cat("\f")
cat("\014").

R download

Taiwan
https://ftp.yzu.edu.tw/CRAN/Department of Computer Science and Engineering, Yuan Ze University
http://ftp.yzu.edu.tw/CRAN/Department of Computer Science and Engineering, Yuan Ze University
http://cran.csie.ntu.edu.tw/

2018年11月11日 星期日

閱讀平台


青春博客來閱讀平台
https://ireader.books.com.tw/

【人文講堂】20141023 - 閱讀 讓人生不一樣的關鍵 - 鄭俊德

 https://www.youtube.com/watch?v=H8heozYEqSE

2018年10月3日 星期三

玩玩運算

視覺化程式
blocky game(作到PondToutor)
blocky game 講義

anaconda download

資料視覺化
2018.10.13
python 資料視覺化(台大蔡芸琤教授)
     學習是什麼?
     gitHub
     爬文
     學生作品

    推薦書籍:Google必修的圖表簡報術

    python 視覺化範例



數值分析
二分法
牛頓法
加密
解密

 爬文
正規表示法

maker
123D(鑽石,指尖陀螺)
2018.10.12
指陀螺的設計理念
bearing 外徑,高度
塑材的厚度
倒角
2指、3指、4指、5指、6指的旋轉速度、時間、轉動慣量


JoyofCode
   pandas 視覺化資料
micro:bit
micro:bit講義

資訊科技

w3school
   if  else
   for loop
   while loop
   function

learnpython.org

素養導向教學(資訊學科中心電子報 2018-09)
認知、技能、情意

project

  1. blocky game(作到PondToutor)
  2. 指尖陀螺
  3. python 視覺化資料
  4. 資訊科技(智慧校園、物聯網、.....)


2018年8月8日 星期三

2018年8月7日 星期二

2018年6月18日 星期一

R program

#dataAnalysis.r
#source("dataAnalysis.r")
my.var<-function(x){
tmp<-x-mean(x);
tmp1<-sum(tmp^2)/length(x);
return(tmp1)
}

my.sigma=function(x){return(sqrt(my.var(x)))}

my.std=function(x){
return((x-mean(x))/my.sigma(x))
}

print.data=function(x){
cat("x=",x,"\n")
cat("mean(x)=",mean(x),"\n")
cat("x-mean(x)=",x-mean(x),"\n")
cat("(x-mean(x))^2=",(x-mean(x))^2,"\n")
cat("var(x)=",my.var(x),"\n")
cat("sigma(x)=",my.sigma(x),"\n")
cat("std(x)=",my.std(x),"\n")
}

x=seq(3,10,2)
print.data(x)

h=c(172,160,162,164,170,168,166)
w=c(60,50,52,58,62,56,54)

cat("heigh=",h,"\n")
cat("weigth=",w,"\n")
par(mfrow=c(3,1))

plot(h,w,xlab="heigh",ylab="weigth",main="scatter x,y")

z.h=my.std(h)
z.w=my.std(w)

cat("std(h)=(h-mean(h))/sigma(h)=",z.h,"\n")
cat("std(w)=(w-mean(w))/sigma(w)=",z.w,"\n")

plot(z.h,z.w,xlab="standardize heigh",ylab="standardize weigth",main="scatter z.h,z.w")

cat("r=sum(z.h*z.w)/n=",sum(z.h*z.w)/length(h),"\n")

my.relation=function(x,y){
Sxy=sum((x-mean(x))*(y-mean(y)));
Sxx=sum((x-mean(x))^2);
Syy=sum((y-mean(y))^2);
r=Sxy/sqrt(Sxx*Syy);
cat("Sxy=",Sxy,"\n");
cat("Sxx=",Sxx,"\n");
cat("Syy=",Syy,"\n");
cat("r=Sxy/sqrt((Sxx*Syy))=",r,"\n");
}

my.relation(h,w)
#regression
#y-mu.y=Sxy/Sxx(x-mu.x)
y=w
x=h
mu.y=mean(y)
mu.x=mean(x)
Sxy=sum((x-mean(x))*(y-mean(y)));
Sxx=sum((x-mean(x))^2);
x.min=min(x)
x.max=max(x)
xx=seq(x.min,x.max,1)
yy=Sxy/Sxx*(xx-mu.x)+mu.y

 lm( y~x )
abline(lm( y~x ))

2018年6月12日 星期二

R for mean, median, mode, var, sd

> x=seq(3,10,2)
> x

[1] 3 5 7 9

> mean(x)

[1] 6

> mean(x+2)

[1] 8

> mean(3*x)

[1] 18

> mean(3*x+2)

[1] 20

> x-mean(x)

[1] -3 -1 1 3

> (x-mean(x))^2

[1] 9 1 1 9

> sum((x-mean(x))^2)/length(x)

[1] 5

> ((x+2)-mean(x+2))^2

[1] 9 1 1 9

> sum(((x+2)-mean(x+2))^2)/length(x)

[1] 5

> (3*x-mean(3*x))^2

[1] 81 9 9 81

> sum(((3*x)-mean(3*x))^2)/length(x)

[1] 45

> sum(((3*x+2)-mean(3*x+2))^2)/length(x)

[1] 45

> x=c(1,2,3,3,3,4,5,6,8)
> x

[1] 1 2 3 3 3 4 5 6 8

> median(x)

[1] 3

getmode <- function(v) {
uniqv <- unique(v)
uniqv[which.max(tabulate(match(v, uniqv)))]
}
> getmode(x)

[1] 3

> x=c(1,4,2,rep(3,3),4,5,6,8)
> x

[1] 1 4 2 3 3 3 4 5 6 8

> sort(x)

[1] 1 2 3 3 3 4 4 5 6 8

> length(x)

[1] 10

> x_sort=sort(x)
> x_sort

[1] 1 2 3 3 3 4 4 5 6 8

> sum(x_sort[5]:x_sort[6])/2

[1] 3.5

> median(x)

[1] 3.5

> getmode(x)

[1] 3

2018年5月27日 星期日

maxima教學

Edwin L. (Ted) Woollett
屏東教育大學
屏東教育大學 應數系
http://www.math.nptu.edu.tw/ezfiles/115/1115/img/626/JHmathG11.pdf 

施文奇的教學檔案


De Morgan Law (迪摩根定理)

(AUB)'=A'nB'
(AnB)'=A'U B'

U:{1,2,3,4,5,6,7,8,9,10}; 
A:{1,2,4,6};B:{1,3,4};

Ap:setdifference(U,A);

Bp:setdifference(U,B);

AuB;union(A,B);

AnB:intersect(A,B);

setdifference(U,AuB);
intersect(Ap,Bp);

setdifference(U,AnB);
union(Ap,Bp);




2018年5月23日 星期三

Html特殊符號

Html特殊符號

數據分析


Excel 函數 中文意義 語法
sum 加總 =sum(B2:B11) 從B2到B11做加總
count 計數 =count(range)
average 平均數 =average(range)
varp 母體變異數
standarize 正規化 =standarize(x,mean,stdevp)
median 中位數
mode 眾數
sqrt 開根號
rank 排名
round 四捨五入 =round(range,小數點第幾位)
trunc 小數捨去
IF 如果 =IF(condition, true, false)
min 最小值
max 最大值
slope 斜率
power 次方
pi 圓周率
exp 指數
fact 階乘
permut 排列
combine 組合
log 對數
ln 自然對數
sumif =sumif(condition,true,false)

期望值
‹X›=E(X)=∑ xi p(xi)=∑xi ⁄n
‹ aX+b ›=a<X>+b=E(aX+b)=aE(X)+b

加權總分=∑ wi xi
加權平均=∑ wi xi ⁄ ∑ wi

變異數
var(X)=∑(xi-μ)2/n=∑xi2/n - μ2
var(aX+b)=a2 var(X)

var(X)=<(X-<X>)2>=<X2-2X<X>+<X>2>=<X2>-<X>2
var(aX+b)=<(aX+b-<aX+b>)2>=a2<(X-<X>)2>=a2<(X-<X>)2>=a2var(X)

標準差=√ 變異數
σ(X)=√var(X)
σ (aX+b)=|a|σ(X)

Lab
X={1,2,3,4,5}
X+2={2,4,6,8,10}
3X={3,6,9,12,15}
3X+2={5,8,11,14,17}
solve the list
<X>,<X+2>,<3X>,<3X+2>
var(X),var(X+2),var(3X),var(3X+2)
σ(X),σ(X+2),σ(3X),σ(3X+2)

標準化
X'=(X-μ)/σ

正規化
[min,max]--->[0,1]

(max-x)/(max-min)=(1-x)/1

x in [min,max]---> x=? in [0,1]


相關係數r
正相關r> 0,負相關r<0,零相關r=0
Sxy=∑i(xix)(yiy)
Sxx=∑i(xix)2
Syy=∑i(yiy)2
r=Sxy/√(Sxx Syy)

迴歸線
y-μy=Sxy/Sxx(x-μx)
斜率=slope=Sxy/Sxx

2018年4月25日 星期三

106-2 高三資訊作業


  1. tracker/SoundCard/labview 作業 40%
  2. Scratch/micro-bit 作業40%
  3. 雷雕照片(去背景)  20%

106-2 高三數學作業

  1. 筆記
    • 集合論
    • 排列
    • 組合
    • 二項式定理
    • Pascal's triangle/聖誕襪定理/大衛之星定理
  2. 數學2習作
    • P.23,  4,5,7,8,9
    • P.29, 2,3
    • P.33, 3
    • P.38, 2 ,6
    • P.40, 11,12 

2018年4月20日 星期五

micro-bit 擴充版


測試滑桿的亮度

滑桿  616~4
micro-bit 0~255
使用micro-bit 設定線性變換 616~4 to 255~0

添加套件
(1)Neopixel


劉正吉老師套件
http://github.com/lioujj

(2)LCD1612

(3)pxt-sensor


如何由電腦抓取micro-bit 資料
(1)install
mbedWinSerial_16466.exe
python-3.6.5.exe
勾選 Add Python 3.6 to path
下載 collect.py

(2)dos模式
pip install pyserial
py collect.py


gitHub  makecode
吉哥分享/makecode




2018年4月11日 星期三

科學技術等級 記錄表 (東華大學 曾賢德教授)


  科技部 自造實驗基地的小科學家培育計畫


   科學技術等級 記錄表 (東華大學 曾賢德教授)


姓名:         年級:
 
姓名請清楚正楷填寫,以利製作證書

學校: 體育中學 日期: 2018 / 04 / 11


主 題
科學等級 技術等級
備 註
1
看見聲音波形
1
A

2
看見聲音頻譜
2
B

3
產生訊號
2
C

4
樂器調音
3
C

5
聲音的速度
4
D

6
拍頻
3
D

7
都卜勒效應
4
D

8
聽聽陀螺的轉速
3
F

9
閃爍的光
(使用太陽能板)
5
C

10
法拉第的磁生電
(使用線圈、磁鐵與指尖陀羅)
6
E





達成等級:



Set

U={1,2,3,4,5,6,7,8,9,10}
A={1,2,4,6}
B={1,3,4}
 
|U|=10
|A|=4
|B|=3
 
A聯集B 
AUB={1,2,4,6,3}
 
A交集B 
AnB={1,4}
 
A的補集 
A'=U-A= {3,5,7,8,9,10}
 
B的補集  
B'=U-B={}
 
AUB的補集

(AUB)'=
 
A交集B的補集  
(AnB)'=
 
(A'nB')=
(A'UB')=
 
 德摩根定律De Morgan's laws(或称笛摩根定理对偶律)
 (AUB)'= (A'nB')
 (AnB)'= (A'UB')

 
 
A與B的差集
A-B={2,6}

 B與A的差集
B-A={3}

 

maxima website

Mathematical Science & Technologies

 

Maxima for Symbolic Computation

 http://mathscitech.org/articles/maxima#book

 

2018年4月10日 星期二

集合,等比數列,等差數列,permutation,combination

 集合(Set)
U:{1,2,3,4,5,6,7,8,9,10};
A:{1,2,4,6};B:{1,3,4};
cardinality(U);
cardinality(A);
cardinality(B);
 
AuB:union(A,B);

AnB:intersect(A,B);

powerset(A);
cardinality(%);
 
Ap:setdifference(U,A);

Bp:setdifference(U,B);

AminusB:setdifference(A,B);

BminusA:setdifference(B,A);

ApnBp:intersect(Ap,Bp);

ApuBp:union(Ap,Bp);


setequalp (a, b)


Returns true if sets a and b have the same number of elements and is(x = y) is true for x in the elements of a and y in the elements of b, considered in the order determined by listify. Otherwise, setequalp returns false.


setequalp(setdifference(U,AuB),ApnBp);

 setequalp(setdifference(U,AnB),ApuBp);

disjoin(A,B); 

disjoin(B,A); 
 
 http://maxima.sourceforge.net/docs/manual/maxima_35.html#SEC188

排列(permutation), 組合(combination)
Function: permutation (n, r)
Returns the number of permutations of r objects selected from a set of n objects.
To use this function write first load(functs).
Function: combination (n, r)
Returns the number of combinations of n objects taken r at a time.
To use this function write first load(functs).

 load(functs);
 permutation(5,3);

combination(5,3);

級數和

Function: arithmetic (a, d, n)
Returns the n-th term of the arithmetic series a, a + d, a + 2*d, ..., a + (n - 1)*d.
To use this function write first load(functs).
Categories:  Package functs · Sums and products

Function: geometric (a, r, n)
Returns the n-th term of the geometric series a, a*r, a*r^2, ..., a*r^(n - 1).
To use this function write first load(functs).
Categories:  Package functs · Sums and products

Function: harmonic (a, b, c, n)
Returns the n-th term of the harmonic series a/b, a/(b + c), a/(b + 2*c), ..., a/(b + (n - 1)*c).
To use this function write first load(functs).
Categories:  Package functs · Sums and products

Function: arithsum (a, d, n)
Returns the sum of the arithmetic series from 1 to n.
To use this function write first load(functs).
Categories:  Package functs · Sums and products

Function: geosum (a, r, n)
Returns the sum of the geometric series from 1 to n. If n is infinity (inf) then a sum is finite only if the absolute value of r is less than 1.
To use this function write first load(functs).
  
load(functs);
 a:1;d:2;n:10;
arithmetic(a,d,n); 
/*an=a+(n-1)d*/
a+(n-1)*d;


r:2;n:10;
geometric (a, r, n)  ;
/*an=ar^(n-1)*/
a*r^(n-1);


b:2;c:3;
harmonic (a, b, c, n);

d:2;n:10;
 arithsum (a, d, n);
/*a+(a+d)+(a+2d)+...+(a+(n-1)d) */
/*Sn=n/2(2a+(n-1)d) */
n/2*(2*a+(n-1)*d);

r:2;n:10;
 geosum (a, r, n);
/*a+ar+ar^2+...+ar^(n-1) */ 
/* Sn=a(1-r^n)/(1-r) */
a*(1-r^n)/(1-r);









2018年3月31日 星期六

106-2數學4,3重修班

數學4重修班
1 3月26日
2 3月27日
3 4月9日
4 4月10日
5 4月16日
6 4月17日
7 4月19日
8 4月23日
9 4月24日
10 4月30日
11 5月1日
12 5月7日
13 5月8日
數學3重修班
1 5月14日
2 5月15日
3 5月21日
4 5月22日
5 5月24日
6 5月28日
7 5月29日
8 6月4日
9 6月5日
10 6月11日
11 6月12日
12 6月14日

2018年3月27日 星期二

micro:bit 作業


micro:bit  內定附加名為*.hex
檔案內定存在"下載"

107.03.28 micro:bit作業
filename:
三愛18溫xx-1愛心
三愛18溫xx-2喜怒哀樂
三愛18溫xx-3AB左右鍵
三愛18溫xx-4剪刀石頭布
三愛18溫xx-4A電子骰子
三愛18溫xx-7口型閃爍燈

2018年3月25日 星期日

Scratch 廣播(broadcast)

Cat  :
Say:"Hello! Dog"
broadcast "dogSay" -(1)
(2)receive "catSay"
say: "Let's go to movies"
轉向-90度
set rotation style "left-right"
broadcast "LetGo" -(3)  
repeat until x position <-270
    move 10 step
    next costume
    wait 0.2

Dog:
(1) receive "dogSay"
say:"Hello! Cat"
broadcast "catSay" -(2)
(3) receive "LetGo"
repeat until x position <-270
    move 10 step
    next costume
    wait 0.2
Cat 程式
Dog 程式


 

2018年3月18日 星期日

106-2 Scratch 課綱


106-2 Scratch 課綱
http://dr9.nksh.tp.edu.tw/





週數/日期
上課主題
第一週

3/1
Scratch 基本介紹
霹靂舞
舞台特效(變色25)ヽ色切換ヽ音效ヽ暫停0.2
第二週

3/15
移動ヽ說ヽ暫停ヽ音效ヽ互相廣播 
計次式迴圈(10次)
第三週

3/29
馬兒跑步ヽ變大變小
計次式迴圈ヽ隨機變數
第四週

4/12
條件式迴圈
第五週

4/26
無窮迴圈背景切換
移動 ヽ旋轉(平行處理

旋轉跟平移要獨立寫,否則動作會干擾.音量設為20%較不會太大聲
第六週

5/24

開車
單向選擇
音效:shaker(taser2沒有)
space rippler


 if x>200
    x=-200
    換車型
第七週

6/7
打地鼠
雙向選擇
第八週

9/6
巫婆打鳥ヽ猴子吃香蕉
全域變數ヽ隨機變數
第九週

9/20
角色變換
分身
第十週

10/4
專題製作
海洋教育ヽ環境教育...
創意發揮
第十一週
10/18
專題製作
海洋教育ヽ環境教育...
第十二週
11/1

成果發表
各組經驗分享

每一作業的心得,至少15~20個字.寫出自己的感想,比如很難:是那個地方很難,後來你怎麼克服?這樣還可以作為自己的筆記!



電流急急棒 演算法
1.造型
  背景
  筆刷/黑色/調為最粗
  黑色:s型路徑
  紅色:終點
  

2.音效
  失敗: shaker
  成功:space rippler

3.程式
   腳色
   --球:黃色
  .開始(綠旗)
    移到:x,y

  .角色被點一下
    不斷重複
      移到滑鼠游標
        if 碰到白色
           播放 shaker
           說:碰到了 (1秒)
           移到:x,y
           停止 這個程式
     
        if 碰到紅色
           播放 space rippler
           說:闖關成功 (1秒)
           移到:x,y
           停止 這個程式

4.造型
  自行繪製新角色
  障礙物:天空色
            十字
            一字

5.程式
  --障礙物:十字角色
    綠旗
      不斷重複
         右轉1度
   --障礙物: 一字角色
    綠旗
      不斷重複
        1秒內,滑行x, y=-69
        1秒內,滑行x, y=29

   --球:黃色角色
     
      .....
      .....
   
      if 碰到白色或天空色
           播放 shaker
           說:碰到了 (1秒)
           移到:x,y
           停止 這個程式
      .....
      .....


開車