uhjish / entropy-calculator

Automatically exported from code.google.com/p/entropy-calculator
0 stars 0 forks source link

ValueError: math domain error #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

it fails with this text:

u'EAP: Threatened Marine Ecosystems Get Boost from USD 4.5 Million Grant from 
the GEF\n\nThe World Bank\u2019s Board of Executive Directors today approved a 
project to support the Capturing Coral Reef and Related Ecosystem Services 
Project, with USD 4.5 million in grant funding provided by the Global 
Environment Facility (GEF). This regional project will design innovative models 
for valuing mangrove, sea grass and coral reef ecosystems services to inform 
policy and decision making for improved environmental stewardship of these 
critical resources.\n\nThe project focuses on Indonesia and the Philippines, 
where coral reefs and related ecosystem services are critical to livelihoods, 
food security and climate resilience, and includes activities to: quantify the 
value and market potential of coral reef and mangrove ecosystem services; forge 
community-led innovation in capturing and sustaining benefits from marine 
eco-system services and enhancing resilience in the face of climate change; and 
promote behavior change through outreach and widely disseminate scientific 
information to inform policy- and decision-making.\n\nCoastal and marine 
resources and their associated ecosystem services in the region are linked to 
globally important marine biodiversity and underpin an enormous part of the 
regional economy.\n\n\u201cCapturing the economic and cultural values of marine 
natural capital through the valuation of ecosystem services, and quantifying 
the cost of lost services due to environmental degradation, has enormous 
potential. We can transform the development and stewardship of coastal areas by 
translating ecological value into financial terms for local stakeholders and 
policy makers,\u201d said Marea Hatziolos, Senior Environmental Specialist and 
the World Bank\u2019s team leader for the project.\n\n\u201cThis wealth of 
natural capital has the potential to be a major driver of inclusive green 
growth in the region, if we overcome some huge challenges. We especially need 
better resource governance regimes, measures to adequately value the 
environment for current and future generations when calculating economic 
benefits, and good scientific information to inform decision making and 
tradeoffs,\u201d she added.\n\nThe world\u2019s biodiversity epicenter lies 
within the Coral Triangle \u2013 an area that extends from the northern 
Philippines to Malaysia in the west, East Timor to the South, Eastern Indonesia 
and Papua New Guinea to the East and trailing off to the Solomon Islands toward 
the Southeast. Here, coral reefs are most abundant and diverse and support 
large populations of people who are highly dependent on coral reef fisheries 
for the livelihoods and food security. In the Western and Central Pacific, 
healthy coral reefs and mangroves form the first critical line of defense 
against storm surge and sea-level rise for low lying islands and atolls.\n\nThe 
GEF grant will be administered by the Global Change Institute of the University 
of Queensland.\n\nThe University is contributing USD 2 million in additional 
financing and research partners will provide another USD 3.9 million in 
contributions. An additional $21.9 million in parallel co-financing is provided 
by World Bank-financed projects: the Coral Reef Rehabilitation and Management 
Program-Coral Triangle Initiative (COREMAP-CTI) in Indonesia and the Rural 
Development Project in the Philippines.\n'

What is the expected output? What do you see instead?

Traceback (most recent call last):
  File "Entropy.py", line 18, in <module>
    H.AnalyseText()
  File "/home/ledermac/devel/mongo/entropy-calculator/EntropyCalculator.py", line 123, in AnalyseText
    self.RankedWords=[(self.Entropy(word),word) for word in self.unique]
  File "/home/ledermac/devel/mongo/entropy-calculator/EntropyCalculator.py", line 72, in Entropy
    result=self.AnalyticEntropy(n)-H
  File "/home/ledermac/devel/mongo/entropy-calculator/EntropyCalculator.py", line 59, in AnalyticEntropy
    result-=self.MarginalProb(m,n)*x*log(x,2)
  File "/home/ledermac/devel/mongo/entropy-calculator/EntropyCalculator.py", line 46, in MarginalProb
    result=LogCombinations(n,m)
  File "/home/ledermac/devel/mongo/entropy-calculator/EntropyCalculator.py", line 16, in LogCombinations
    result-=lgamma(x-y+1)
ValueError: math domain error

What version of the product are you using? On what operating system?
svn trunk, Python 2.7.2, linux

Please provide any additional information below.

Original issue reported on code.google.com by christian.ledermann on 31 Oct 2013 at 1:49

GoogleCodeExporter commented 8 years ago
Ah OK I get it I have to play around with the set_words_per_part parameter for 
smaller texts

Original comment by christian.ledermann on 31 Oct 2013 at 3:36