|
[Date Index]
[Thread Index]
[Author Index]
Re: Problems with my first package: Statistics`Common`RegressionCommon`BestFitParameters instead of BestFitParameters
- To: mathgroup at smc.vnet.net
- Subject: [mg58177] Re: [mg58049] Problems with my first package: Statistics`Common`RegressionCommon`BestFitParameters instead of BestFitParameters
- From: Mathematica Ezine <ezine at omegaconsultinggroup.com>
- Date: Tue, 21 Jun 2005 06:02:51 -0400 (EDT)
- References: <200506170918.FAA07763@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Without seeing the package, it's difficult to say for sure what the
problem is. So I'll make an educated guess. It's a common problem when
using the Statistics` packages. What I have here is also described at:
http://omegaconsultinggroup.com/Services/HTMLLinks/ezv2i03_4.html
You don't have the correct contexts in your BeginPackage command.
In[1]:=<<Statistics`NonlinearFit
This makes both NonlinearRegress and BestFitParameters available to the
user.
In[2]:= Complement[{"NonlinearRegress", "BestFitParameters"}, Names[]]
Out[2]={}
So you may be tempted to use this in your package.
BeginPackage["MyPackage`", "Statistics`NonlinearFit`"]
This does load Statistics`NonlinearFit`.
It does make NonlinearRegress available to you package.
It does *not* make BestFitParameters available to you package.
Why?
In[3]:=Context[NonlinearRegress]
Out[3]=Statistics`NonlinearFit`
In[4]:=Context[BestFitParameters]
Out[4]=Statistics`Common`RegressionCommon`
Statistics`NonlinearFit` loads another package to get the definition of
BestFitParameters, but it does not automatically make the context of
that package available to your package.
The best analogy I've heard for this is: A friend of my friend is not
necessarily my friend. So the correct thing to do is explicitly list
the context of all symbols you want to use in your package:
BeginPackage["MyPackage`", "Statistics`NonlinearFit`",
"Statistics`Common`RegressionCommon`"]
----------------------------------------------
Omega Consulting
The final answer to your Mathematica needs.
http://omegaconsultinggroup.com
On Jun 17, 2005, at 4:18 AM, frank wrote:
> Hello,
>
> thanks to some hints I got on this list, I have managed to write my
> first package.
>
> There was one problem with options, but I solved this with the help of
> the list archive: It wouldn't accept {verbosity->0} because it is
> something different than Schulerstuff`ConstrainedFit`Private`verbosity.
> But with the help of
>
> http://forums.wolfram.com/mathgroup/archive/1994/Apr/msg00041.html
>
> and a
>
> verbosity::usage="foo";
>
> this works now. However, there remains one problem. Within a function
> in the package that is exported, I do
>
> ExportedFunction[whatever_,options___]:=Block[{...},
> ...
> RegressResult=NonlinearRegress[...]
> ...
> Return[Switch[verbosity /. {options},
> 0, BestFitParameters /. RegressResult,
> 1, {NMinResultReport, RegressResult}
> ]];
> ]
>
> With verbosity->0, everything is fine now, but with 1 I get:
> ...
> Statistics`Common`RegressionCommon`BestFitParameters -> {a -> 0.500455,
> b -> 0.999833},
> ...
>
> where I expected simply
>
> BestFitParameters -> {a -> 0.500455, b -> 0.999833},
>
> Can you tell me, without me creating a minimal example, what I can do
> to
> simplify the Return value?
>
> Regards, Frank
> --
> Frank Küster
> Inst. f. Biochemie der Univ. Zürich
> Debian Developer
>
Prev by Date:
Re: Re: Nested Commutators
Next by Date:
Re: Re: can anyone solve this equation?
Previous by thread:
Problems with my first package: Statistics`Common`RegressionCommon`BestFitParameters instead of BestFitParameters
Next by thread:
Re: Problems with my first package: Statistics`Common`RegressionCommon`BestFitParameters instead of BestFitParameters
|