MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Scope problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35983] RE: [mg35972] Scope problem
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sun, 11 Aug 2002 05:13:41 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Bobby,

This is what I replied.
_____________________________________
Try

BeginPackage["`glibb`",
{"Statistics`ContinuousDistributions`","Statistics`Common`DistributionsCommo
n`"}
]

Then use can use the function CDF directly. This seems to be a common
pitfall. Naming Statistics`ContinuousDistributions` in the BeginPackage
statement is not sufficient, because it is actually an underlying package
that exports CDF and other names.
_________________________________________

But I winged it and testing now I found that I also needed to add

BeginPackage["`glibb`",
{"Statistics`ContinuousDistributions`","Statistics`Common`DistributionsCommo
n`","Statistics`NormalDistribution`"}
]

If you name package XYZ in the BeginPackage statement, that does NOT make
the names in any package that XYZ loads directly available to you the
package writer. CDC is actually exported by Common`DistributionsCommon, and
NormalDistribution is actually exported by NormalDistributions`. WRI does
not exactly make that clear (especially NormalDistribution) and so people
are always falling into this trap. There are some similar examples in the
Units package.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

From: DrBob [mailto:majort at cox-internet.com]
To: mathgroup at smc.vnet.net

Aaron,

When I add the line

<<Statistics`ContinuousDistributions`

directly after your BeginPackage statement, it works properly, but if I
add the following line instead, it doesn't:

Needs["Statistics`ContinuousDistributions`"]

BeginPackage issues a Needs statement anyway (according to Help), but
that doesn't seem to be good enough.  Apparently you must load the
package.

I'm new to packages myself, so this totally mystifies me.

Bobby

-----Original Message-----
From: Aaron [mailto:au198295 at hotmail.com]
To: mathgroup at smc.vnet.net
Subject: [mg35983] [mg35972] Scope problem

I have been having difficulty using the distribution packages.  In a
package I created, I can't get the CDF function to evaluate, and I
can't figure out the problem. Below I have included a very simple (and
useless) package I created that runs in to the same problem.  I want
to use the numerical value of the CDF for a normal distribution. When
I call TestFunction, this is the output:

Global`glibb`Private`CDF[Global`glibb`Private`NormalDistribution[0,
1], -1]
Global`glibb`Private`CDF[Global`glibb`Private`NormalDistribution[0.,
1.], -1.]

Calls to CDF return similar outputs in my useful packages.  The
package I am currently working with was originally written for
Mathematica 2.0, and I am trying to update it to work with 4.0.  I was
told that all the functions were tested thoroughly in the 2.0
implementation and worked fine.


TEST PACKAGE: file "glibb.m"
------------------------------------------------------------
BeginPackage["`glibb`",
{"Statistics`ContinuousDistributions`"}
]

glibb::usage = "glibb is a test package."

TestFunction::usage = "TestFunction[]."

Begin["`Private`"]

TestFunction[] := Module[{alpha,alpha2},
	alpha = CDF[NormalDistribution[0,1], -1];
	Print[alpha];
	alpha2 = N[CDF[NormalDistribution[0,1],-1]];
	Print[alpha2];
];

End[ ]

EndPackage[ ]
-------------------------------------------------------------

Thanks In Advance,
Aaron





  • Prev by Date: Re: Re: ALL roots of non-polynomial equation
  • Next by Date: RE: Re: ALL roots of non-polynomial equation
  • Previous by thread: RE: Scope problem
  • Next by thread: Notebook for Primes