MathGroup Archive 2008

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

Search the Archive

Re: Compiled PDF & CDF Issues

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90602] Re: Compiled PDF & CDF Issues
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Tue, 15 Jul 2008 06:18:27 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <g5f60t$rdb$1@smc.vnet.net>

Benedetto Bongiorno wrote:

> Below listed is my notebook "HypergeometricDistributionErrors.nb" that shows
> the following:
> 
> When I use the PDF or CDF functions I get the correct answers.
> 
> When I use the compiled PDF or CDF functions I get the correct answers but
> CompiledFunction::cfse errors.
> 
>  
> 
> I cannot figure what I am doing wrong.

Nothing really wrong, except that you try to compile a function 
(HypergeometricDistribution) that is *not* compilable by Compile[].

Compile[] can do its job only on functions that accept and return 
numbers and/or booleans (i.e. _Integer, _Real, _Complex, and True or 
False types) either as scalars or as non-ragged arrays (says vector or 
matrices, ...).

Now, HypergeometricDistribution[] returns neither a scalar nor an array, 
but an object of type HypergeometricDistribution.


     In[1]:= HypergeometricDistribution[5, 12, 20]

     Out[1]= HypergeometricDistribution[5, 12, 20]

     In[2]:= CDF[%, 2]

     Out[2]= 287/969


Regards,
-- Jean-Marc

> Mathematica V 6.0.3
> 
> OS Microsoft Windows XP Professional x64
> 
>  
> 
> I thank you ahead for you advice.
> 
>  
> 
>  
> 
> Ben Bongiorno
> 
>  
> 
> Notebook start******************************************
> 
> Table[{k,CDF[HypergeometricDistribution[5,12,20],k]},{k,0,5}]
> 
> {{0,7/1938},{1,56/969},{2,287/969},{3,224/323},{4,613/646},{5,1}}
> 
>  
> 
> Compile[{sample,populationMarked,population,xMin,xMax},
> 
>  
> Table[{k,CDF[HypergeometricDistribution[sample,populationMarked,population],
> k]},{k,xMin,xMax}]];
> 
> %[5,12,20,0,5]
> 
> CompiledFunction::cfse: Compiled expression
> HypergeometricDistribution[5.,12.,20.] should be a machine-size real number.
> 
> 
> CompiledFunction::cfex: Could not complete external evaluation at
> instruction 13; proceeding with uncompiled evaluation. 
> 
> {{0,7/1938},{1,56/969},{2,287/969},{3,224/323},{4,613/646},{5,1}}
> 
>  
> 
>  
> 
> Table[{k,PDF[HypergeometricDistribution[5,12,20],k]},{k,0,5}]
> 
> {{0,7/1938},{1,35/646},{2,77/323},{3,385/969},{4,165/646},{5,33/646}}
> 
> Compile[{sample,populationMarked,population,xMin,xMax},Table[{k,PDF[Hypergeo
> metricDistribution[sample,populationMarked,population],k]},{k,xMin,xMax}]];
> 
> %[5,12,20,0,5]
> 
> CompiledFunction::cfse: Compiled expression
> HypergeometricDistribution[5.,12.,20.] should be a machine-size real number.
> 
> 
> CompiledFunction::cfex: Could not complete external evaluation at
> instruction 13; proceeding with uncompiled evaluation. 
> 
> {{0,7/1938},{1,35/646},{2,77/323},{3,385/969},{4,165/646},{5,33/646}}
> 
> Notebook end*********************************************************
> 



  • Prev by Date: Re: Compiled PDF & CDF Issues
  • Next by Date: Re: Compiled PDF & CDF Issues
  • Previous by thread: Re: Compiled PDF & CDF Issues
  • Next by thread: Re: Compiled PDF & CDF Issues