Showing posts with label math. Show all posts
Showing posts with label math. Show all posts

Sunday, September 04, 2011

เลขท้ายสองตัวที่ผ่านมา

สืบเนื่องจากโพสท์เรื่องใบ้เลขเด็ดที่ผมเขียนไปครับ ผมลองไปดูว่าเลขท้ายสองตัวที่ออกมา 158 ครั้งที่ผ่านมาออกเลขไหนมากเลขไหนน้อยครับ ผลที่ได้เป็นดังนี้สำหรับเลข 00, 01, 02, ..., 98, 99:


เลขท้ายสองตัวเป็นไปได้ทั้งหมด 100 แบบ ตั้งแต่ 00 ไปถึง 99  เมื่อดูในข้อมูล 158 งวดถ้าทุกตัวเลขออกเท่าๆกันก็ต้องออก 1.58 ครั้ง (ที่วาดเป็นเส้นประ) แต่ในความเป็นจริงเลขบางตัวออกมากกว่า 1.58 ครั้ง เลขบางตัวออกน้อยกว่า 1.58 ครั้ง แต่การกระจายรอบๆ 1.58 คล้ายๆกับเป็นเลขที่สุ่มออกมา ไม่สามารถชี้ว่าเลขท้ายสองตัวไหนออกมามากหรือน้อยอย่างผิดปกติครับ (เพราะจำนวนที่เราดูมันน้อย มีแค่ 158 ตัว จำนวนครั้งที่มากๆหรือน้อยๆมันอาจจะเกิดจากความฟลุ้คได้ง่ายๆ)

ผมดูการแจงแจงข้อมูลของตัวเลข 0-9 ในเลขท้าย 2 ตัวและเลขท้าย 3 ตัวด้วย และไม่พบว่ามีเลขไหนออกผิดปกติครับ  หวยออกงวดหน้าผมคงใบ้ตัวเลขสุ่มเหมือนเดิม :-)

ปล. ตารางข้อมูลสำหรับเลขท้ายสองตัวเป็นดังนี้ครับ:

ตัวเลขจำนวนครั้งที่ออก
001
011
021
032
040
055
062
071
081
092
103
113
124
131
141
151
160
172
181
190
201
210
222
231
242
253
263
272
281
292
301
310
321
332
342
352
362
370
380
390
400
413
421
433
443
452
461
470
483
492
502
511
520
531
541
552
562
570
582
592
600
611
622
631
642
651
663
673
682
694
700
713
720
732
740
751
763
771
780
791
802
814
820
830
840
854
861
872
883
890
900
911
922
934
942
952
964
974
982
991

Friday, September 02, 2011

ใบ้เลขเด็ด

เมื่อวานเป็นวันหวยออก ผู้คนใน Facebook ต่างกล่าวกันถึงหวยตั้งแต่เช้า ผมจึงร่วมสนุกด้วยโดยการให้เลขเด็ดซะเลย โดยผมเลือกสุ่มเลขมาสี่ตัวเป็น 0 3 8 7:


พอดีมีคนถามว่ามีหลักการอะไรไหมในการให้ตัวเลข ผมก็บอกไปว่าผมเดามั่วเลย แต่ถ้าถูกคนก็จะจำได้ พอผมกลับบ้านผมเลยสงสัยว่าในตัวเลข 0-9 เนี่ย มีตัวเลขไหนออกมากกว่าชาวบ้านไหม ผมเลยไปโหลดเลขหวยที่ออกย้อนหลังไปถึง 30 ธันวา 2548 แล้วมานับดูว่า 0 ออกกี่ครั้ง 1 ออกกี่ครั้ง ไปเรื่อยๆจนถึง 9 ออกกี่ครั้ง

ผมได้ตัวเลขมาทั้งหมด 159,580 ตัว ดังนั้นถ้าไม่มีเลขไหนออกมากกว่าเลขอื่นเป็นพิเศษแล้ว เลข 0-9 ก็ควรออกมาไม่ห่างจาก 15,958 ครั้งนัก  ผลจากการนับคือ

ตัวเลขจำนวนครั้งที่ออก
015863
115929
216097
315959
415770
516009
615893
715881
816050
916129


แม้ว่าบางเลขจะออกมาก บางเลขจะออกน้อย แต่จำนวนครั้งที่ออกก็ใกล้เคียงกับ  15,958 ไม่มีเลขใดออกมากหรือออกน้อยเป็นพิเศษครับ

กราฟจำนวนครั้งดูเป็นอย่างนี้ครับ (เส้นประคือ 15,958 และโชว์ช่วงระหว่าง 15,000 ถึง 16,300 จะได้เห็นชัดๆ ถ้าโชว์ตั้งแต่ 0 ถึง 16,300 จะเห็นจุดต่างๆทาบเส้นประหมดเลย):



*** * **** * ****** *********
ปล. รายละเอียดเผื่อมีใครอยากทำคล้ายๆกันบ้าง

1. สำหรับผู้ที่สนใจเรื่องสถิติ Pearson's chi-square เป็นดังนี้ครับ (ผมป้อนเข้า R แทน Mathematica เพราะกำลังทดลองใช้ R ทำงานบริษัทอยู่ครับ):

> chisq.test(c(15863, 15929, 16097, 15959, 15770, 16009, 15893, 15881, 16050, 16129), p=c(0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1))

Chi-squared test for given probabilities

data:  c(15863, 15929, 16097, 15959, 15770, 16009, 15893, 15881, 16050,      16129)
X-squared = 7.2059, df = 9, p-value = 0.6157

2. ผมไปโหลดหน้าเว็บผลล็อดเตอรี่จาก http://lotto.mthai.com/ ครับ

3. ผมใช้ BeautifulSoup มาดึงข้อมูลออกจากหน้าผลล็อตเตอรี่ครับ

4. ใช้ Mathematica วาดกราฟดังนี้ครับ: 
ListPlot[data, PlotStyle -> PointSize[0.02], Filling -> Axis, 
 PlotRange -> {15000, 16300}, 
 AxesLabel -> {"ตัวเลข", "จำนวนครั้งที่ออก"}, 
 Epilog -> {Dashed, Line[{{0, 15958}, {9, 15958}}]}]

Tuesday, March 01, 2011

มาใช้เงินกันเถอะ

ถ้าผมมีเงินเหลือใช้สัก 5 ล้านบาทผมจะจ้างคนแปลหรือทำซับไตเติ้ล Khan Academy (http://www.khanacademy.org/) ให้เด็กๆ คุณพ่อคุณแม่ และคุณครูเมืองไทยจำนวนมากๆใช้ช่วยการเรียนการสอน ตอนนี้ภรรยาผมดูใหญ่เลยเพื่อไว้สอนลูกๆ

ค่าใช้จ่ายในการทำการแปลไปเรื่อยๆไม่น่าเกินเดือนละแสน ตอนแรกต้องใช้เงินเยอะหน่อยเพื่อให้แปลบทเรียนที่มีอยู่เสร็จเร็วๆ

ใครรู้จักแหล่งเงินถ้าทำได้รีบทำเลยนะครับ ปริมาณเงินที่ใช้น้อยกว่ารถสปอร์ต แต่สามารถยกระดับปัญญาประชากรได้เยอะนะครับ

Friday, January 21, 2011

A Few Webpages For Math Teachers And Learners

If you are teaching math to kids or if you find math interesting, here are a few websites that you might enjoy.

The Virtual Math Tutor site contains solved math problems for high school and college levels.

Math Magic contains a bunch of mathematical puzzles that you might enjoy. The archive goes back to 1998.

Project Euler contains puzzles for math and programming. The intended audience would "...include students for whom the basic curriculum is not feeding their hunger to learn, adults whose background was not primarily mathematics but had an interest in things mathematical, and professionals who want to keep their problem solving and mathematics on the edge."



Monday, November 15, 2010

Doing Math Homework With Wolfram Alpha

I wonder how many kids will do their homework by hand if they find out that Wolfram Alpha can do most math homework for them.

For example, going to http://www.wolframalpha.com and type "solve x^2 + y^2 = 1 and x y = 1/2" will give you this page with graphs, symbolic and numerical solutions:


For some problems, Wolfram Alpha can provide step-by-step solution. For example, finding the derivative of 1/cos(x^2) gives the solution and related information. When we click on the "Show steps" link, we get to see this:


Integrals can be done easily. Typing "integrate 1/(1+ 2x + 5x^2)" and clicking "Show steps" gives you this:


Wolfram Alpha can provide step-by-step solutions for many of high school and college math problems I tried; standard math homework that asks the students to "show their work" would be easily done by Wolfram Alpha.

Thursday, September 30, 2010

An Interesting Book: The Big Questions, By Steven E. Landsburg


This is a marvelous book. Steven Landsburg attempted to answer some interesting questions* with ideas from mathematics, economics, and physics! If you have a chance, you should take a look at it--it should provide you with new perspectives on many things, even if you disagree with it.

-----------
*Questions like "Why is there something instead of nothing?", "Where does mathematical knowledge come from?", "How to tell Right from Wrong?", "How not to be a jerk?", etc.

Sunday, August 08, 2010

Chronology of Computation of π

π, the ratio between the circumference and the diameter of every circle on a flat plane, has been calculated to 5 trillion digits using a big personal computer in 2010.

Since π is irrational, the number of digits is infinite and we will calculate even more digits in the future. Beyond a few tens of digits or so, the exercise is done mostly to improve our computational techniques and to test hardware reliablity (and of course, some bragging rights.) Engineering calculations only need at most 16 digits to cover all conceivable projects on earth. All intergalactic calculations in the future should not require more than 64 digits or so.

Wikipedia has a chronology of the π computation and I've plotted the number of digits vs. year below. Note the log scale of the vertical axis.


There seem to be three phases of techniques/technologies involved in the computations of π throughout the history. The first part is from a few thousands years ago until 1400 A.D. or so where calculations were done mostly with geometric figures. The second part is from 1400 to 1900 A.D. where calculations were done manually using infinite series. The third part is after 1946 where electronic computers and fast-converging series were used. The three parts correspond to the three different slopes of the plot above.

After 1946, with electronic computers, the number of digits seems to grow approximately exponentially. This might reflect the exponential advance in computer speed since a small number of infinite series families were used in the computations. Here's the plot after 1946:




For more interesting info, check out Wikipedia's page on the history of π calculations.

Saturday, March 27, 2010

Content Aware Fill

Yesterday, I was very impressed and amazed by the video showing the Content Aware Fill feature in the upcoming version of Photoshop. I was wondering what kind of algorithm made that feature possible. Today, I stumbled on a blog post showing that this feature has been available for the Gimp (an open source image editor) for some time. The image processing plugin is called Resynthesizer. Resynthesizer is described in Paul Harrison's Ph.D. thesis.



A few other interesting algorithms for content aware editing can be found here.

Thursday, January 21, 2010

เบอร์มรณะ (จริงๆ)!!!

อ่านข่าวเบอร์มรณะแล้วผมก็ได้แต่ขำ เพราะว่ามันเป็นไปไม่ได้ที่เสียงจากโทรศัพท์จะทำให้เลือดคั่งในสมองได้ นอกจากตัวโทรศัพท์จะเกิดการระเบิดเวลายกหูฟัง หรือใช้โทรศัพท์ขณะขับขี่ยานพาหนะแล้วเกิดอุบัติเหตุ

แต่เชื่อไหมครับว่ามันมีลำดับตัวเลขมากมาย ที่ถ้าผู้ฟังฟังจนจบ(หรืออ่านจนจบ)แล้ว ต้องตายทุกคนไปไม่มีข้อยกเว้น ผมจะยกตัวอย่างมาหนึ่งอันดับก่อน และจะบอกแค่ตัวเลขต้นๆเท่านั้นจะได้ไม่มีใครตาย

เอาละนะ ถ้าไม่อยากเห็นอย่าอ่านต่อ




เอาละ 6 ตัวแรกเท่านั้น 3 1 4 1 5 9 ไม่บอกตัวที่เหลือ เดี๋ยวเอาไปใช้ฆาตกรรมกัน

ปล. ข้อมูลเพิ่มเติมเรื่องเบอร์โทรมรณะเก๊ที่นี่ และเบอร์มรณะตัวจริงที่ถ้าอ่านจนหมดจะตายได้ที่นี่

Sunday, December 27, 2009

Interesting Warnings About Power Law Distributions

I've wondered about some data that might be distributed according to a certain power law and I found these two links to be informative: So You Think You Have a Power Law — Well Isn't That Special? and Power-law distributions in empirical data.

The abstract of the paper in the second link reads:

Power-law distributions occur in many situations of scientific interest and have significant consequences for our understanding of natural and man-made phenomena. Unfortunately, the detection and characterization of power laws is complicated by the large fluctuations that occur in the tail of the distribution -- the part of the distribution representing large but rare events -- and by the difficulty of identifying the range over which power-law behavior holds. Commonly used methods for analyzing power-law data, such as least-squares fitting, can produce substantially inaccurate estimates of parameters for power-law distributions, and even in cases where such methods return accurate answers they are still unsatisfactory because they give no indication of whether the data obey a power law at all. Here we present a principled statistical framework for discerning and quantifying power-law behavior in empirical data. Our approach combines maximum-likelihood fitting methods with goodness-of-fit tests based on the Kolmogorov-Smirnov statistic and likelihood ratios. We evaluate the effectiveness of the approach with tests on synthetic data and give critical comparisons to previous approaches. We also apply the proposed methods to twenty-four real-world data sets from a range of different disciplines, each of which has been conjectured to follow a power-law distribution. In some cases we find these conjectures to be consistent with the data while in others the power law is ruled out.

Thursday, October 15, 2009

I Learned Something New Today: Automatic Differentiation


After 28 years of (amateurishly and rather clumsily) programming computers and 25 years of using calculus, I just found out about a method to calculate numerical derivatives exactly (up to numerical accuracy.)

I knew how to do numerical differentiation based on approximating derivatives with finite differences which incurs inexactness due to truncating infinite series, but I never thought about how to get exact numerical results. Luckily someone else did, and we got the automatic differentiation technique.