Results 1 to 7 of 7

Math Help - Problem with Mathematica Statistics'NormalDistribution'

  1. #1
    Newbie
    Joined
    Jun 2009
    Posts
    4

    Problem with Mathematica Statistics'NormalDistribution'

    Hey there,

    I'm getting a very odd error, and I would be grateful for any help solving it.

    I have a notebook with the following:

    (* Amy's program to generate random orthogonal matrices (RUM) and sort their \
    eigenvalues (EigenRUM)*)
    << LinearAlgebra`MatrixManipulation`
    << Statistics`NormalDistribution`
    RUM[NxN_] := (
    f[x_, y_] := Random[NormalDistribution[0, 1]];
    RM1 = Array[f, {NxN, NxN}];
    RM2 = QRDecomposition[RM1];
    R1 = Flatten[Drop[RM2, 1], 1];
    f2[x_] := R1[[x, x]]/Abs [R1[[x, x]]];
    R2 = Array[f2, NxN];
    R3 = DiagonalMatrix[R2];
    Q1 = Flatten[Take[RM2, 1], 1];
    Q2 = Conjugate[Transpose[Q1]];
    Transpose[Q2].Q2;
    RM = Q2.R3);

    I wrote this over two years ago, and several members of my department and I have been using it happily since - until today, when it has suddenly started throwing up errors - specifically:

    NormalDistribution::shdw: Symbol NormalDistribution appears in multiple \
    contexts {Statistics`NormalDistribution`, Global`}; definitions in context \
    Statistics`NormalDistribution` may shadow or be shadowed by other definitions.


    The notebook has not been altered since it was last working, so I am very confused as to why it now has errors.

    I also get the error

    Random::randt: Type specification NormalDistribution[0, 1] in \
    Random[NormalDistribution[0, 1]] should be Real, Integer, or Complex.


    on running

    Random[NormalDistribution[0, 1]]
    by itself. I've read through the help page on NormalDistribution, but even trying to input the examples from there throws up errors.

    Anyone who can shed any light on this will receive a lot of gratitude, as my PhD is kinda at a standstill unless I can generate random orthogonal matrices!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by AmyMarieMason View Post
    Hey there,

    I'm getting a very odd error, and I would be grateful for any help solving it.

    I have a notebook with the following:
    (* Amy's program to generate random orthogonal matrices (RUM) and sort their \
    eigenvalues (EigenRUM)*)
    << LinearAlgebra`MatrixManipulation`
    << Statistics`NormalDistribution`
    RUM[NxN_] := (
    f[x_, y_] := Random[NormalDistribution[0, 1]];
    RM1 = Array[f, {NxN, NxN}];
    RM2 = QRDecomposition[RM1];
    R1 = Flatten[Drop[RM2, 1], 1];
    f2[x_] := R1[[x, x]]/Abs [R1[[x, x]]];
    R2 = Array[f2, NxN];
    R3 = DiagonalMatrix[R2];
    Q1 = Flatten[Take[RM2, 1], 1];
    Q2 = Conjugate[Transpose[Q1]];
    Transpose[Q2].Q2;
    RM = Q2.R3);
    I wrote this over two years ago, and several members of my department and I have been using it happily since - until today, when it has suddenly started throwing up errors - specifically:

    NormalDistribution::shdw: Symbol NormalDistribution appears in multiple \
    contexts {Statistics`NormalDistribution`, Global`}; definitions in context \
    Statistics`NormalDistribution` may shadow or be shadowed by other definitions.

    The notebook has not been altered since it was last working, so I am very confused as to why it now has errors.

    I also get the error

    Random::randt: Type specification NormalDistribution[0, 1] in \
    Random[NormalDistribution[0, 1]] should be Real, Integer, or Complex.

    on running
    Random[NormalDistribution[0, 1]]
    by itself. I've read through the help page on NormalDistribution, but even trying to input the examples from there throws up errors.

    Anyone who can shed any light on this will receive a lot of gratitude, as my PhD is kinda at a standstill unless I can generate random orthogonal matrices!
    Has the version of M. been updated?

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jun 2009
    Posts
    4
    No, Mathematica hasn't been updated since the Autumn.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Super Member
    Joined
    Aug 2008
    Posts
    903
    First thing just restart Mathematica and see if the problem is resolved then:

    NormalDistribution has been added to the built-in functions in ver 6 and 7. Did you guys upgrade? If so, then just omit <<Statistics`NormalDistribution from your code. You can verify if it's a built-in function with:

    Names["System`NormalDistribution"]

    which returns:

    {"NormalDistribution"}

    on my ver 7 meaning it's now part of the "System" context so if I were to enter:

    <<Statistics`NormalDistribution

    I would now have two variable names with the same name, one in system context and the other in "Statistics" context and Mathematica would use the first one on the context search path unless I explicitly specified the context name and would also give me an error like you got.

    Also, don't use upper case variable names since all the built-in function names begin with upper case names and this might cause conflict.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Jun 2009
    Posts
    4
    Quote Originally Posted by shawsend View Post
    First thing just restart Mathematica and see if the problem is resolved then:
    Restarting definately does not solve the problem. So far we've tried this on two computers, connecting to three different servers on the university farm (We don't have personal copies of Mathematica, but the department has three different machines that run it we can access) - all give the same errors.

    Quote Originally Posted by shawsend View Post
    NormalDistribution has been added to the built-in functions in ver 6 and 7. Did you guys upgrade? .
    The sys admin says there have been no upgrades since the Autumn, and the problem only appeared on Friday (ie. running without errors Friday morning, errors from early Friday afternoon)

    Quote Originally Posted by shawsend View Post
    If so, then just omit <<Statistics`NormalDistribution from your code. You can verify if it's a built-in function with:

    Names["System`NormalDistribution"]

    which returns:

    {"NormalDistribution"}

    on my ver 7
    Typing
    Names["System`NormalDistribution"]
    Returns
    {}
    Restarting Mathematica, and just entering

    Random[NormalDistribution[0,1]
    gets the error

    Random::randt: Type specification NormalDistribution[0, 1] in \
    Random[NormalDistribution[0, 1]] should be Real, Integer, or Complex.

    So I don't think it can be that NormalDistribution is part of the "System" context.


    But thanks for the help!
    Last edited by AmyMarieMason; June 15th 2009 at 05:34 AM. Reason: adding thanks
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Super Member
    Joined
    Aug 2008
    Posts
    903
    What version do you have?

    Now, startup Mathematica and try this:

    Enter:

    ?NormalDistribution

    You'll get a definition if it's a built-in function or empty list if it's not.

    If it's not yet defined, then enter:

    <<Statistics'NormalDistribution
    ?NormalDistribution

    That should load the package "Statistics with the function NormalDistribution and the ?NormalDistribution should then give you a description of the function.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Jun 2009
    Posts
    4
    Version 5.0.1.0

    Typing

    ?NormalDistribution gets:

    Information::notfound: Symbol NormalDistribution not found.


    Typing ...

    Okay, now that is super duper weird. It just started working again.

    I'm not sure what just happened, but it seems to have fixed itself - no error messages, producing random numbers, running the whole notebook happily.

    Sometimes, I really hate computers...

    Thank you very much for your time
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Mathematica problem
    Posted in the Math Software Forum
    Replies: 0
    Last Post: October 14th 2010, 05:33 AM
  2. Mathematica Problem
    Posted in the Math Software Forum
    Replies: 8
    Last Post: March 16th 2010, 11:00 AM
  3. Mathematica problem
    Posted in the Math Software Forum
    Replies: 2
    Last Post: December 16th 2009, 08:19 AM
  4. the problem in mathematica
    Posted in the Math Software Forum
    Replies: 2
    Last Post: November 6th 2009, 12:25 PM
  5. Mod and If Problem [Mathematica]
    Posted in the Math Software Forum
    Replies: 1
    Last Post: October 1st 2008, 10:02 AM

Search Tags


/mathhelpforum @mathhelpforum