Java and Matlab - URGENT

Hi,

There was this program in matlab which was converted to java. My problem is that I am not getting the exact results like the matlab version .  For example, if I were to run it 5 iterations , it is somewhat similar..and If i were to run it for 500 iterations..the result is not really similar...

My question is that lets  say I use  the Java's nextGaussian, nextFloat to replace the Matlab randn,rand..

Would the result be different because I am using different languange.....
Matlab              Java
randn              nextGaussian()
rand                nextFloat()
Jasbir21Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jasbir21Author Commented:
Is it possible to have a program converted and display the exact same results....
0
avinthmCommented:
Hi ,

The methods you are using are random number generators.
So the results may not be the same.

If you can tell more details abt your class requirement then we can help you

cheers
0
Mayank SAssociate Director - Product EngineeringCommented:
Random numbers generated will anyway always change, that is why they are 'random'. Did you expect to see the same numbers getting generated everytime?
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Jasbir21Author Commented:
actually, the random generators are the core of the program and is used to simulate a simulation. My question, lets say i program is converted from matlab to java, does it behave the same way....

For example,in Matlab i use rand, but in java is nextFloat()...both are random generators...but would the values produced by the exact same...i know that if it is random generators, it is not going to produce the values at that same time..

I mean lets say Matlab produces value 0.789 and the number of times it produces it would be different than java right ?? pls advice..
0
Mayank SAssociate Director - Product EngineeringCommented:
>> but would the values produced by the exact same

I guess not.

>> I mean lets say Matlab produces value 0.789 and the number of times it produces it would be different than java right

I think so.
0
Jasbir21Author Commented:
Is there a way to confirm coz I need to run tests to explain why is it not similar ?
0
avinthmCommented:
when you run your application in matlab, even then u cant predict what rand function is going to return.
random number generation is the same, regardless of any language.
one cant predict the number that would be generated.

i think this explaination would be more convincing. :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mayank SAssociate Director - Product EngineeringCommented:
>> Is there a way to confirm coz I need to run tests to explain why is it not similar ?

The simple means to do it is to run 2 simple programs (one random number generator in Java and one in MatLab) a number of times and see the output for yourself.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.