顯示具有 ideas 標籤的文章。 顯示所有文章
顯示具有 ideas 標籤的文章。 顯示所有文章

2009年6月4日 星期四

A method to count the prime number

When I was writing about this method to count the prime number, I realize it could overestimate them by assuming that all factors are prime, or underestimate them by ignoring them. Therefore we can safely conclude that the number of prime number is within the range define by upper limit and lower limit.

2009年6月1日 星期一

一個質數分佈的統計方法(2)

我上次提出了兩個在一定數值範圍內估計質數數量的方法,但是一個方法像香港的司法精神寧縱無枉,於是會把質數因子也忽略,因此低估了質數的總數;另一個方法像中共國對付互聯網異見一樣寧枉無縱,於是自然不會把質數因子忽略,因此會高估了質數的總數。取其中庸之道,我們可以拿前一種方法為質數數量的下限,後一種方法為質數數量的上限,結果便可估算在一定數值範圍內質數的總數。

2009年5月31日 星期日

Reminding System for Bus passager

It is a common scene that many passagers slept when they take a bus. I suppose it wouldn't be surprise to find out that Hong Kong citizen would be the most likely to slept in public transportation(compare to US citizen who perfer to read novel.) However, that would place passager in a delimma since s/he could easily oversleep thus missing the destination.

My solution to this problem is my Reminding System for Bus passager or RSB. The system is exceedingly simple to build with IC but not CPU. When a passager board a bus, there is a screen in front of him/her; s/he can thus enter his/her destination by rolling a mouse point or using a touchpad. (Former is easy to wore down and later is more resilent.) For every click/forward/backward motion of the ball, it would add or minus a value in the IC stored there; and the name or details of that station is retrived from the central databus thus displayed. After the passager chose the destination and clicked confrim on screen, then this value is stored in the IC. As the bus driver arrived at each station, s/he press a button to changed the value stored in the master IC. A simple electrical circuit is then use to compare the value stored in individual IC and central IC, once it detected an exact match, it would then activate the alert system. The alert system could be as simple as Electric shock system with high voltage and little current in the form of ring which passager could wear on their wrist. It would alert the passager using series of mild electric shocks.

This system would cost much lesser to build than a fully computerized system with expansive hardware and custom-tailored software on monopolized Operating System, and it serve the purpose of making sure the passager could enjoy a light sleep during the travelling.

2009年5月15日 星期五

小主意:巴士到站提示器

可能香港人是世界上最經常在巴士、地鐵等的交通工具中睡覺的人,在外國的人,多數是看書及報紙的,因為巴士車程不是固定,人人得練自動自覺在抵達目的地時醒來的神功,要是你未達到此修行,則一是你會因小睡而誤點,得不償失;又或者你活該,決不可在乘車中途小睡。我的小小發明/提議.就是為想小睡卻不想因此而誤點的人度身訂造,巴士公司用了此提議,可令更多乘車選乘巴士,因為它在其他人數沒有上限的公共交通工具難以實行。
我的想法名為巴士到站提示器,就是乘客在上巴士坐下以後,在他/她前面有小型螢幕可供他/她輸入目的地,如果乘客不介意的話,用LED來顯示也可以,乘客可用上下滾動的鼠標來選取自己的目的地,或者用觸摸式的輸入裝置會更耐用,從而減低了轉動時的摩擦損耗,之後它會把目的地當成數字來儲存在超小型記憶體,輸入完之成乘客可放心小睡片刻(或者可考慮多加一製作確認及取消)。當資料被輸入電子裝置之後,每當巴士抵達一站時,中央IC處理器會發出增加1的訊號到各乘客的巴士到站提示系統,而這系統還有IC或簡單的電子線路專責比較目的地的數字和中央系統發出的訊號,要是一致時則啟動乘客座位的千人震裝置,以三數次高壓低電荷來刺激乘客的皮膚神經(通常是頸部,但亦可是是一技小型的金屬官或環,可讓乘客穿在手腕或任何敏感地方上)。考慮再周全一點的話可以由巴士司機負責發訊號,他/她在到站前三/四分鐘按一按製,則可喚醒在小睡片刻的乘客,如此一來則沒有乘坐會因為憩息片刻而誤點,比現在的顯示器更有效。
如果巴士公司接納此方案,我只要求自己、家人及女朋友以後可免費乘巴士,次數及路程不限!

2009年5月2日 星期六

好古怪及無聊的小主意(1)

(又是另一個本來可以伸請專利的主意來獻世,自己得不到任何益處,唯一最欣慰這點是看到有人善用我的主意,彷如看到自己的孩子快高長大,造福社會。)

小時侯的體育鞋的底常常穿,再入石仔,走路時不舒服。
不過現在想來其實是有益身心健康,特別對長者及行動不便者有複康及行氣活血之效,做法就是在穿鞋時在內隴放入石仔(或小型的波子),如此只要你不怕痛,你就可以邊行街邊做腳底按摩,不知不覺間改善自己的血液循環,而不用專程搭車上深圳去做腳按摩。不過要小心選擇石頭,怕痛的人可選表面平滑一點的石頭,如想效果更好及更快,則不妨選一些表面尖一點的,可謂苦口良藥;另外,要注意不要連續多用過一星期,最好是兩三天後停用一天,以免腳下的皮膚硬化。

2009年4月30日 星期四

一個質數分佈的統計方法

又是時代已久遠到無從躇考的主意,當時剛剛升上中一,興致勃勃要拿一個諾貝爾數學獎,其中一個開心大發現是質數的分佈,是當時在研究如何寫一個找一個數的因子,由此去統計世上所有的質數,但是如此文,遇到了死迴圈便放棄了,心想人腦比電腦聰明的地方在於人腦可以自行發現解決不了的問題(Infinite recursion)而放棄的,而電腦就不懂,一定要寫程式的人去代它發現,電腦並不聰明,而是寫程式的人聰明!

今天似乎是解決了,但想必早有其他數學家發現了!

我的思路是:
1. 因為一個數的因子最大只可能是它的平方根,即任何數在某意義上都涵蓋了它的平方,由它的性質去決定在它平方範圍內的數是不是質數;
2. 另外,再考慮到所有非質數的分佈,例如2的倍數出現在任何數字的機會是2份1.3的倍數出現在任何數字的機會是3份1,N的倍數出現在任何數字的機會是N份1,只要除去該範圍內的所有部數,剩下的一定非質數不可。
1是決定了質數範圍,2是用反向思維來提供找質數的方法,關門可以打狗!

所以結論是:
質數在N^2內的機會率為:
1-[(2的倒數+3的倒數+4的倒數+...N的倒數)-(2...N的倒數的所有組合,如此是減去多數一次的因子,例如4是2的部數)]

出問題了!
因為2也是2的倍數,3也是3的倍數,如此類推,即如果因子本身是質數,在我算法內也會被當成非質數,因為我的算法本身不是用來決定一個數是不是質數,我的算法只可以排除一定不是質數的數字,所以此算法只可以作為近似值,用來比較N平方到(N+1)平方的質數分佈,不可以推出一個絕對值。

(後記,現在剛想到的是可不可冒險犯難,把所有因子自動當成質數而加入算式內呢?因此變成:
1-[(2的倒數-N平方的倒數+3的倒數-N平方的倒數+4的倒數-N平方的倒數+...N的倒數)-(2...N的倒數
的所有組合,如此是減去多數一次的因子,例如4是2的部數)]
或:
1-[(2的倒數+3的倒數+4的倒數+...N的倒數)-(2...N的倒數的所有組合,如此是減去多數一次的因子,例如4是2的部數)-N的倒數]
未解決,未解決,未解決!)

2009年4月20日 星期一

A method to approximate the distribution of Prime numner

The idea is following my idea to find all the factors of a number. We know that for a number X, all its factor could be found within square of X. So for N^2, at most it will have N factors, or it will have none except 1 and N.

Since we also know that the factor of 2 has a probability of 1/2 in any natural number; the factor of 3 has a probability of 1/3 in any natural number; thereby the factor N has a probability of 1/N in any natural number. We thus can find the prime by eliminate all known factors.

To count the prime number within range of 1 to N^2 is thus,

[1-(1/2+1/3+1/4+...+1/N-(Any combinations of 1/2,1/3....1/N))]*N

Now consider the various range:
For N=2, the probability of a prime=1-1/2=1/2,
which is 2.
For N=3, the probability of a prime=1-(1/2+1/3-1/6)=1/3,
the prime numbers are 2,3,5,7 which is 4/9;
there is a difference of 1/9.

How come? Because when counting prime numbers, we discount 2,3 because they are also the multiple of 2 and 3.

We can assume that as N become greater, the different would be smaller.

2009年4月19日 星期日

某一條數學假說及它的推廣

說出來也為羞愧的,因為我自中四第一次見到此假說,過了超過十年竟然想不出如何用嚴僅的推理來證明,而它也是超級複雜的東西,它只有兩條演算規律:

A. 如果是單數則加1,
B. 如果是雙數則除2;
要證明的是任何一個正整數,在經過有限的步驟後最終一定會陷入1-2-1的死迴圈;

我想來想去的結論都是: 如何證明任何一個正整數都可以用2的升冪來表示呢?
即任何數=n(1)*2^0+n(2)*2^1+n(3)*2^2+.....n(k)*2^(k-1)

只要能證明此前設,其實即2進制可以成立的基礎,則不難證明任何一個單數:
A. 一定是先經A步再行B步,得出比本身少的數值,如25,26,13,14,7,8,4,2,1,因此這是遞減數列,數值只會愈來愈細,不會愈來愈大,因為數值本身是有限,所以最終一定在經過有限的步驟後最終一定會陷入1-2-1的死迴圈;

如果是任何一個雙數,同理會形成遞減數列,數值只會愈來愈細,不會愈來愈大,再分兩類:
A. 2的完整乘冪,如2的7次方128,則會直降到1,最終一定會陷入1-2-1的死迴圈,步驟數為2的完整次方數;
B. 2的不完整乘冪,如2的7次方加6次方192,則會經歷一有限次數的B步而成為單數,在此例中則是經歷6次B步後成為3,因為是單數,所以可以應用上面單數的證明來解決。

算不算證明完畢?

其實有更有趣的事,我想問的是到底在十進制可以有幾多條如此的假說,是不是有限數?而每一個假說又有什麼特色?
例如用三條演算規律:
A. 如果用3除剩1時是加2,
B. 如果用3除剩2時是加1,
C. 如果用3可整除時是除3,
要證明的是任何一個正整數,在經過有限的步驟後最終一定會陷入3-1-3的死迴圈;

單是加不夠好玩,不如改成:
例如用三條演算規律:
A. 如果用3除剩1時是減2,
B. 如果用3除剩2時是加1,
C. 如果用3可整除時是除3,
要證明的是任何一個正整數,在經過有限的步驟後最終一定會陷入3-1-3的死迴圈;

留意到什麼沒有?
理論上,我可以隨便作一條出來:
A. 如果用5除剩1時是減2,
B. 如果用5除剩2時是加1,
C. 如果用5可剩3時是減3,
D. 如果用5除剩4時是加1,
E. 如果用5可整除時是除3,
要證明的是任何一個正整數,在經過有限的步驟後最終一定會陷入5-1的死迴圈。

(未完待續....)

2009年4月15日 星期三

中文輸入法的另一個主意

上次我談及改良中文輸入法的方向是減低使用者對某一輸入法的依賴,強迫使用者每次使用同一輸入法時要留神螢幕,因為每次出現的中文字順序不同;(我還未想到有什麼方式可以取替目前以字形或筆劃為本的中文輸入法。)而今次的方向則相當正路,就是如何改善使用者輸入中文的效率?

而本慨念發明有四個組成部份:

A.可動態由D修改的中文字碼對應表,該種中文輸入法的中文字輸出由此提供;

B.利用數據庫來記錄使用者使用某一種中文輸入法的習慣,主要以字碼輸入的組合為索引值;

C.使用習慣數據分析器,分析使用者使用該種中文輸入法時的習慣,用同一組字碼輸入中這些字最常用,這些字通常不用,當然,這是最簡單的方法,可以用更複雜的方法如Bayesian分析法來分析使用者使用某一中文輸入法中某一組字碼的習慣;

D.執行者用一早設定好的內建條件,利用C的方法來比較,計算某一組字碼輸入法中各中文字的最佳順序,以此來更新A的中文字碼對應表,令使用者打中文字的效率提高。

Yet another Idea on Chinese input method

Now this idea is truly about how to increase the efficiency and the speed of inputing Chinese character. Not that I am going to suggest a new paradigm to input Chinese without using keystrokes which each keystroke is associated with certain aspect of the Chinese character, I am thinking in the direction which the program can dynamically alter the correspondence table which the Chinese input method rely on. For instance, much like search engine would provide search suggestion while the user is entering the inquiry using statistically method, this new paradigm of Chinese input method would 'learn from the experience' of the pattern of how this Chinese input is used by this user, then dynamically place the most frequent choice in the front as priority choice in order to save user's time to look for the Chinese character which s/he is typing.(Or to learn more complex pattern of the input given all of us have enough computing cycle that we waste.)

This innovation require three components:

A. A correspondence table that can be dynamical updated by D each time it is loaded;

B. A recorder and counter program to run in the background whatever this Chinese input method is called. It would record the frequency of the user's choice of Chinese character everytime and keep a database with various variables.

C. A statistic program to analyze the data collected in B. It could be ranged from simplest implementation like taking the most frequent choice as the preferred choice by moving it to the front or more difficult implementation involve Bayesian statistical method.

D. By applying the result gathered from A to compare against the fixed criteria provided by programmer, this module update the content inside A so A would be optimized for this user.

一個古怪的中文輸入法主意

說古怪這主意真的很古怪,因為一般分析/設計/改良中文輸入法的人都會向如何增加輸入中文的速度及準誠度去想,決不會像我一樣把問題的方法倒轉去想的,因為我想解決的問題不在於中文輸入法是否好用實用,我意會的問題在於當一個人太熟悉一種中文輸入法時,他/她輸入中文便成了反射反應,他/她根本不用看鍵盤甚至是螢幕便知道自己打了什麼字,理論上可以令他/她的腦神經有更多的資源去進行更高階的運算如遣詞用字、文章組織及思想內涵等,但缺點就是打中文字的機械化,他/她失去了認知心理學中最低層反應的靈活性;要是一天有一種更新更好的輸入法時,他/她就失去了適應的能力,所以本文章的思路就是如何令使用者保持打中文字的靈活性?

要解決這問題很簡單,相信要實現也會太複雜,就是把目前的固定的中文編碼表改為可動態更新的,而每一次使用者使用完的時侯,就會把當中的中文順序更新,例如本來今次用某輸入法打ABCD得出來的是Q,W,E,R,T,Y;而下一次用同一種輸入法再打ABCD得出來的可能是W,E,R,T,Y,Q又或者是R,T,Y,Q,W,E...等等,因為每次出現的中文字順序不同,因此使用者不可能依賴習慣,看都不用看螢幕便打完一篇文章,否則一定會錯漏百出, 如此便強迫使用者每次用同一輸入法更新一下使用者的神經網絡,令使用者保持頭腦靈活!

2008年12月27日 星期六

彈珠機可以加的主意

彈珠機可以加的主意:

1. 加分及減分制,在機中的某處加入可轉動的扇葉,
被擊中時可以順時針轉(加分),或逆時針轉(減分);又或者是相反,甚至是隨機,例如可以亮紅/錄燈,紅燈時順時針轉是加分,逆時針轉時是減分;而綠燈時逆時針轉會加分,順時針轉會減分。如果分數趺至零甚至是負即「Game Over」,如此一來遊戲的變化較多。
(應可用簡單的電子線路做成,可轉動的磁加結合微型發電機,
逆時針轉時正電壓;逆時針轉負電壓,用偵測電壓線路來決定是加減分;紅綠燈則是隨機決定電壓,然後再和正負電壓作邏緝運算,如兩者正或負則加分,兩者不同則減分。)

2. 下面有孔,球經過時會趺進去,加減分,或扣一個球。

3. 通常波子機是用地心吸力來令波子向由玩家負責控制的活門方向移動,用彈簧作波子向上活動的力量來源。但如果波子用鐵,即受磁場影響之物料來造,而波子機是平躺的,換句話說,波子不是由本身的重量主導運動方向。而是由波子機廂旁的XYZ方向放置的電磁石的電流強度來決定,由磁場來代替以前地心吸力場的作用,玩家如果想波子「輕」一點,甚至像「air hockey」般無摩擦力自由浮動,只要把Z軸的磁場扭為負數,於是波子被磁力吸起,四處飄浮,彈力極強。(如果嫌上下的電磁線圈太礙眼,可以用磁石做波子,上南下北,但波子機廂的高度不足夠它翻轉。);同理,左右/前後亦可用電磁石的電流強度來決定(即改變左右的「重量」,前後的「重量」)。如此是我稱為偏(激)波子遊戲,如果波子夠輕的話,左右/前後磁場又相差無幾的話,就可以令波子的活動千變萬化,展現「deterministic chaos」的風采。

一般來說,XYZ的磁場強度可由玩家決定,但亦可以隨機決定,例如每局都保持同一左右、前後、上下的磁場平衡,或者左右、前後、上下的磁場隨機變化,又或者是由玩家的波子打中波子機的位置來決定,如A位置順時針轉則加強左方的磁力,B位置逆時針轉則加強下方的磁力,C位置順時針轉則加前方的磁力,如此類推,即用家當時的行為可即時改變遊戲的環境參數,令遊戲變化多端,百玩不厭。

註: 1和3不可以同時用。

2007年3月28日 星期三

Suggestion for Linux hardware detection

After I restructure the hard drives in my computer, the only distribution in my computer: Fedora refuse to work.
The reason: what is written in the fstab and what it detect in hardware is different. Actually, it is troublesome for these who change hardware often (like carrying the hard drive away for work) to change the configuration from shell every time they use a new computer. I suspect that maybe only for Fedora, but it is most likely all distribution has a fixed fstab and check accordingly in the boot time.

My suggestions are:
1. Why don't all distribution adapt a Live-CD-like hardware detection scheme? i.e. The fstab and everything is dynamically change every in each boot time, therefore saving user the time to rewrite the fstab.
2. Why there is all the stupid Master, Slave jumper on hd and cd/dvdrom so the computer can't recognize a hardware even though it is already connected? Why can't we have an architecture that doesn't require jumper to distinguish between master and slave?
Master and Slave is only determine by its physical connection, nothing more.
3. Why can't there be more than one version of a library exist in the same distribution? What is the harm if two versions of the same library exist? Since the program would know which version of library it needs anyway, why we must have a single version only. That would resolve the trouble for incompatible program that require two versions of the same library.