MathGroup Archive 2008

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

Search the Archive

Re: Compiled PDF & CDF Issues

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90586] Re: Compiled PDF & CDF Issues
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Tue, 15 Jul 2008 06:15:27 -0400 (EDT)
  • References: <g5f60t$rdb$1@smc.vnet.net>

Hi,

have you ever speculated that Compile[] may not always be faster ?
and that it is nonsense to compile a function like
Compile[{sample,populationMarked,population,xMin,xMax},
 
Table[{k,CDF[HypergeometricDistribution[sample,populationMarked,population],
k]},{k,xMin,xMax}]]

where the compiled code look like

{{1, 5}, {94, 258, 3, 0, 4, 3, 0, 3, 3, 0, 5}, {28, 5, 0}, {7, -1,
   1}, {7, -1, 2}, {94, 258, 2, 0, 0, 2, 0, 2, 2, 0, 3}, {64, 3, 1, 3,
   1}, {7, -1, 2}, {4, 8}, {15, 0, 2, 7}, {18, 3, 7, 5}, {12, 5,
   6}, {54, Function[{sample, populationMarked, population, xMin,
     xMax}, HypergeometricDistribution[sample, populationMarked,
     population]], {k, 3, 0, 6, Block}, 3, 0, 0, 3, 0, 1, 3, 0, 2, 3,
   0, 3, 3, 0, 4, 3, 0, 5}, {55, CDF, 3, 0, 5, 3, 0, 6, 3, 0, 7}, {67,
   6, 7, 3, 2}, {66, 1, 2, 1}, {5, 2, 0, -7}, {2}}

what means that the most time is spend to call the
  Function[{sample, populationMarked, population, xMin,
     xMax}, HypergeometricDistribution[sample, populationMarked,
     population]]

that is not compiled at all ?

Regards
   Jens

Benedetto Bongiorno wrote:
> Members,
> 
>  
> 
> 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.
> 
>  
> 
> 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: genetic algorithms
  • Previous by thread: Re: Compiled PDF & CDF Issues
  • Next by thread: import FortranForm back