0

I need to use a number of functions from theStatistics`Library` namespace. Since that is a bit of a mouthful I would like to import it, but I get errors:

In[42]:= Needs["Statistics`Library`"]

During evaluation of In[42]:= Get::noopen: Cannot open Statistics`Library`. >>

During evaluation of In[42]:= Needs::nocont: Context Statistics`Library` was not created when Needs was evaluated. >>

Out[42]= $Failed

In[43]:= << Statistics`Library`

During evaluation of In[43]:= Get::noopen: Cannot open Statistics`Library`. >>

Out[43]= $Failed

I can use individual functions from the namespace

In[44]:= Statistics`Library`DistributionDimensionality[

NormalDistribution[]]

Out[44]= 1

so the problem is not in the name.

What is the problem then? What is the correct way to do the import?

Daniel Mahler
  • 1,095
  • 8
  • 16
  • I don't think you can "load" these in that way (could be wrong though), why not just set up some aliases, e.g. ``dd = StatisticsLibraryDistributionDimensionality, thendd[NormalDistribution[]]` does it... – ciao Apr 19 '14 at 23:06
  • 2
    It's a good idea to give some context for your question and link back to the original thread that prompted this. Statistics`Library` is not a package, so it can't be loaded. (Loading is triggered by the use of some other stats functions.) It is a context (namespace) containing functions meant for internal use: there's no documentation, no guarantee these functions will work properly or that they won't crash your kernel or cause memory leaks, and they're likely to change in future versions. – Szabolcs Apr 19 '14 at 23:26

1 Answers1

7

Statistics`Library` does not correspond directly to a package path, so it cannot be loaded with Get or Needs. Rather, this contents of this context come from

FileNameJoin[{
 $InstallationDirectory, "SystemFiles", "Kernel", "SystemResources", $OperatingSystem,
 "Statistics", "Library.mx"
}]

which is loaded automatically at startup. Loading this file populates the context, but does not add anything to the context path.

It is straightforward to change the context path, however:

AppendTo[$ContextPath, "Statistics`Library`"]

Now:

DistributionDimensionality@NormalDistribution[] (* -> 1 *)
Oleksandr R.
  • 23,023
  • 4
  • 87
  • 125