1 Pages (4 items)
Random function usage problems - Messages
#1 Posted: 8/25/2010 3:36:20 PM
Hi,
I am starting since a few weeks to use Smath Studio and I like it a lot.
In the hoping to understand it better I am testing some functions, the example attached is related to the Random function that in my modest opinion exhibits a strange behaviour as you can see below:

It looks like that at each assignment the function value that I have evaluated at the beginning and put in the vector M is evaluated again ( not in the vector but on the right side of the equal symbol) .
This way we have the illusion to assign something that is static/costant and this is not true
.
Don't know if this is by design but my feelings having used it in Excel or in other application is that its valus need to change only when I press the recalculate button ( and has to change everywhere at the same way ) and not at each assignement of a value that is linked to it.
Hope that I have explained correctly this issue.
Best regards
Francesco
I am starting since a few weeks to use Smath Studio and I like it a lot.
In the hoping to understand it better I am testing some functions, the example attached is related to the Random function that in my modest opinion exhibits a strange behaviour as you can see below:

It looks like that at each assignment the function value that I have evaluated at the beginning and put in the vector M is evaluated again ( not in the vector but on the right side of the equal symbol) .
This way we have the illusion to assign something that is static/costant and this is not true

Don't know if this is by design but my feelings having used it in Excel or in other application is that its valus need to change only when I press the recalculate button ( and has to change everywhere at the same way ) and not at each assignement of a value that is linked to it.
Hope that I have explained correctly this issue.
Best regards
Francesco
#2 Posted: 8/25/2010 4:08:22 PM
Hello Francesko,
Solution of this is simple. You can define your variable M this way (using "eval" function):
[MATH=eng]M←eval(mat(random(10),random(10),random(10),1,3))[/MATH]
or to use originaly defined:
[MATH=eng]M←mat(random(10),random(10),random(10),1,3)[/MATH]
and right click on it and choose Optimization=>Numeric. In either way you will get a set of data that will not change during the subsequent use:
[MATH=eng]M=mat(9,2,5,1,3)[/MATH]
[MATH=eng]M=mat(9,2,5,1,3)[/MATH]
[MATH=eng]M=mat(9,2,5,1,3)[/MATH]
If you want another random data set, just recalculate page (F9) as you requested:
[MATH=eng]M=mat(5,2,3,1,3)[/MATH]
[MATH=eng]M=mat(5,2,3,1,3)[/MATH]
[MATH=eng]x←M[/MATH]
[MATH=eng]x=mat(5,2,3,1,3)[/MATH]
Regards,
Radovan
Solution of this is simple. You can define your variable M this way (using "eval" function):
[MATH=eng]M←eval(mat(random(10),random(10),random(10),1,3))[/MATH]
or to use originaly defined:
[MATH=eng]M←mat(random(10),random(10),random(10),1,3)[/MATH]
and right click on it and choose Optimization=>Numeric. In either way you will get a set of data that will not change during the subsequent use:
[MATH=eng]M=mat(9,2,5,1,3)[/MATH]
[MATH=eng]M=mat(9,2,5,1,3)[/MATH]
[MATH=eng]M=mat(9,2,5,1,3)[/MATH]
If you want another random data set, just recalculate page (F9) as you requested:
[MATH=eng]M=mat(5,2,3,1,3)[/MATH]
[MATH=eng]M=mat(5,2,3,1,3)[/MATH]
[MATH=eng]x←M[/MATH]
[MATH=eng]x=mat(5,2,3,1,3)[/MATH]
Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#3 Posted: 8/25/2010 5:20:09 PM
Radovan is absolutely right. It is because random function defined inside the Numeric Library of SMath Studio and cannot be implicitly called by Symbolic Engine (by default all definitions are proceeds with Symbolic Library nor Numeric one).
To see it with your eyes just try to hover M variable definition with a mouse cursor (when math region is not in focus) - you'll see a Tip with current symbolic expression representation and it will have random(..) functions in the matrix cells instead of numbers.
Regards, Andrey Ivashov.
To see it with your eyes just try to hover M variable definition with a mouse cursor (when math region is not in focus) - you'll see a Tip with current symbolic expression representation and it will have random(..) functions in the matrix cells instead of numbers.
Regards, Andrey Ivashov.
#4 Posted: 8/26/2010 1:55:03 AM
Radovan,Andrey,
thanks a lot for your prompt replay, now everything is clear . It is clear too that I have missed the basic of the way of operating of the program and the next time will be much more carefull in using it and will not start immediately to fire questions.
Thanks again
Francesco
thanks a lot for your prompt replay, now everything is clear . It is clear too that I have missed the basic of the way of operating of the program and the next time will be much more carefull in using it and will not start immediately to fire questions.
Thanks again
Francesco
1 Pages (4 items)
-
New Posts
-
No New Posts