Skip to main content
1-Visitor
December 16, 2015
Question

rnorm vector units

  • December 16, 2015
  • 2 replies
  • 5362 views

I am trying to use rnorm to create a vector of random numbers.

The vector should have (density) units of lb/ft^3.  For some reason when I attempt to give the sigma and mu values units of lb/ft^3, the numbers come out incorrect and without the desired units.  Where should I look to fix this?

Thanks,


Jason

2 replies

23-Emerald IV
December 16, 2015

That's because the default units in Mathcad are SI units. Your inputs (mu and sigma) are provided by you with units. Mathcad translates them internally to SI and then generates the list of random numbers. Unfortunately the random number generator is not designed to handle units, so it simply forgets them. You get a vector of unitles numbers

If you add the units you want to the output, you should see your familiar values, but the unit (lb/ft^) gets prepended with m^3/kg, to make sure they remain uniitless.

Because of the limitation in the random number generator, you should just generate the numbers you want (as in your second attempt) and multiply the result with lb/ft^3.

Success!

Luc

25-Diamond I
December 16, 2015

LucMeekes wrote:

That's because the default units in Mathcad are SI units. If you add the units you want to the output, you should see your familiar values.

Looks like it would not be that easy:

Werner

25-Diamond I
December 16, 2015

My Prime 3.0 can't read your P3.1 file (crazy enough) but I was able to duplicate the problem you describe.

The values are coverted to base units and used (and returned) without any unit. Clearly not as it should be and it looks like Prime is not unit aware to the degree we would like it to be.

Workaround could be to call rnorm without units and ad the desired unit manually.

If mu and sigma should be variables with units, you will have to divide by the proper unit when you call rnorm.

Regards, Werner

jdugas1-VisitorAuthor
1-Visitor
December 16, 2015

Werner,


Many thanks for this solution.  This will move me forward.  It is unfortunate that MathCad is in such a state that these bizarre work-around are required.  Hopefully one day the product will be improved so that it is as intuitive to use as it should be.

Thanks again for your help.


Sincerely,


Jason Dugas

25-Diamond I
December 16, 2015

Many thanks for this solution.

You are welcome.

Hopefully one day the product will be improved so that it is as intuitive to use as it should be.

Hopefully one day Prime will be as advanced as Mathcad 14/15 used to be 10 years ago. 😞

No, what you demand will not work as expected in the old version either and concerning unit awareness Prime really has undergone some improvements. But there is so much missing and so many things are so much slower and more awkward to handle in Prime. Its a shame.

Werner