erik10

I have a degree in Mathematics and Physics from the Danish University Aarhus, comparable to a masters degree with thesis - majoring in Mathematics. In 1991-92 I was a visting scholar at UCLA, Los Angeles, following graduate courses in Applied Mathematics. Since 1992 I have been a teacher in a high school (gymnasium) in Denmark. Special interests: Applied mathematics, graphics and popularizing Mathematics.

MaplePrimes Activity


These are replies submitted by erik10

Thanks, Carl. I think I can't see anything in front of my nose after several changes. I wonder though, if there are some of my commands or datastructures which could be more efficient. For example I read here:

http://www.maplesoft.com/support/help/Maple/view.aspx?path=sum

that it is better using the add command instead of the sum command! With your correction it is down to 40 sec for me now, which is pretty good already, but still it could be interesting if it could be done even better.

 

Erik

Thanks, Carl. I think I can't see anything in front of my nose after several changes. I wonder though, if there are some of my commands or datastructures which could be more efficient. For example I read here:

http://www.maplesoft.com/support/help/Maple/view.aspx?path=sum

that it is better using the add command instead of the sum command! With your correction it is down to 40 sec for me now, which is pretty good already, but still it could be interesting if it could be done even better.

 

Erik

Carl, you are right that the two Matrix definitions of obs and forv should be kept outside of the for loop. This brought the execution time down by half a minut to about 4 min 30 sec. 

The idea behind how a random contingency tabel is created is described on the figure below: Initially the matrix obs (observed values) has all zeros. Then one at a time the random numbers in the sample A is being treated. Dependent on the value of the random number, a specific entrance in the matrix obs is raised by 1. In the end the matrix contain numbers with a sum equal to Total. Then the expected matrix forv can be calculated and finally the Q-value ...

 

 

@Carl Love I have uploaded the code, making a few changes. I throw the histogram command out from the Code Region. I have also changed the comments into english, so you will be able to understand better.

The whole thing is dealing with the Chi-Square test for independence as outlined by Karl Pearson in 1900. I want to test if the Chi Square distribution is a good approximation to the distribution of the possible Q-values of a contingency tables of a fixed size (r rowes, c columns) and fixed total number of observations, Total. To do so, I need a large number (=Size) of random Contingency Tables. To create just one table I need a whole sample of random numbers - in the code called A. Every random number in A will be placed in a specific "drawer" in the table, dependent on its value. When all random numbers of A have been treated, the table hos received it's content and I can calculate its Q-value. Now I repeat this process a large number of times (=Size), until I have a list or matrix of all Q-values. Then I can finally display the Histogram and compare it with the real ChiSquare distribution. It actually works out pretty good as you can see in the file. I just want to make it faster, so I can eventually raise the number of repetitions ...

Simulation_Contingen.mw

I hope this helps? I know it will be quite confusing if you don't know the technique of Chi Square for Independence.

Erik

@Markiyan Hirnyk Thanks to both of you. I think I understand now. As pointed out by Carl, I need one randomize() at the beginning to secure that I won't get the sample sample after each restart. On the other hand I need to remove the randomize() command after each new sample. The reason is that calling the randomize() will call the System Clock, and if each call is happening very fast like in a for loop, it will get the same input and therefore the same sample. I just read the latter in the help menu. So one randomize(), but no more. 

Erik

@Markiyan Hirnyk Thanks to both of you. I think I understand now. As pointed out by Carl, I need one randomize() at the beginning to secure that I won't get the sample sample after each restart. On the other hand I need to remove the randomize() command after each new sample. The reason is that calling the randomize() will call the System Clock, and if each call is happening very fast like in a for loop, it will get the same input and therefore the same sample. I just read the latter in the help menu. So one randomize(), but no more. 

Erik

@tiradentes Now it is a long time since my first question. In the meanwhile Maple 17 has been released. If you are running that version, I can probably explain it. Neither Ctrl+= nor Ctrl+Alt+0 is working on my Danish keyboard, as is the case for you too. As a betatester on Maple 17, I commented on the same problem. I was told it was a bug. Ctrl+Alt+0 should work on our International keyboards, at least for a number of countries. Then I was told that accidentally the combination Ctrl+Alt+Shift+0 is working, and it really does work on my keyboard. The latter is not supposed to work, but the former is. Maplesoft wasn't able to solve the problem before the date of the release of Maple 17. I was told, that it is high priority to repair this bug. I hope it still is, and maybe will be solved in an update. Until then try Ctrl+Alt+Shift+0. It is awkward but better than nothing ...

Erik

Jakubi, I am really more concerned on how it looks on the screen than what is taking place behind the scene. I guess the way you outline is how it was done in Maple 16, right? Isn't this implementation robust enough? And isn't it possible to still have the improvements in the way the variables are listed in the Variables Palette in Maple 17 along with the coloring? In my view Maple have had the CAS program with the best mathematical typography for many years now. It is a pity if they should compromise here ...

 

 

 

Acer, I read your previous comments you linked to. I am delighted to know that you also think Maple animations are old fashioned and ready for a brushup! Today I use Geogebra for animations, but I would have preperred producing them in Maple!

Erik

I succeeded in finding a way out by defining several animate commands and finally combining them in a display command. I am however still puzzled why this animation needs to take up such a large space. Using 100 frames it takes my Intel i7 computer 19 seconds to save the file and the file is about 10 MB. As mathematically defined objects I would assume it to be much faster and the file to me much smaller ...

Regards,

Erik

I am aware it is not an Epicycle. Therefore I used the addition 'simplified'. There is the Mathematical Epicycloid you refer to and the Epicycle constructed by Ptolemy to describe planetary motions and the latter is quite complex including Equants etc. Anyway the name is really not the question here. I just want to have the big circle as a background image (fixed), the small circle rotating on the big one (without trace) and the ball's motion traced. I don't really see how this is done.

Erik

I am aware it is not an Epicycle. Therefore I used the addition 'simplified'. There is the Mathematical Epicycloid you refer to and the Epicycle constructed by Ptolemy to describe planetary motions and the latter is quite complex including Equants etc. Anyway the name is really not the question here. I just want to have the big circle as a background image (fixed), the small circle rotating on the big one (without trace) and the ball's motion traced. I don't really see how this is done.

Erik

Thanks Georgios. It seems like it is not possible to access a Table from a programming environment. I guess that has not been changed in version 16 ...

Erik

Thanks Georgios. It seems like it is not possible to access a Table from a programming environment. I guess that has not been changed in version 16 ...

Erik

Thanks. Your link gives me some other useful information. But what I really asked for: Is it possible to write a program that generate a table with borders of the same kind as when you manually use the menu Insert > Table...? If so, I also want to generate content in the cells. Maybe it is not possible?

Erik

First 9 10 11 12 13 14 15 Page 11 of 17