Message Boards Message Boards

1
|
16468 Views
|
15 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Calculating the popularity of languages over a set of countries

Posted 10 years ago

Hi all

I'm quite new to Alpha and have a specific question, I'm not sure if Wolfram Alpha is able to calculate? I have a set of countries and I want to know what the popularity of those languages are over all the countires combined (both a percentage and number of people), if possible with a breakdown for each country. For interest this is the list of countries where Wikipedia Zero is available, which is a service to give Wikipedia with no data charges in predominantly countries in the global south. http://wikimediafoundation.org/wiki/Wikipedia_Zero.

Thanks

John

POSTED BY: John Cummings
15 Replies

Sorry it was one extra opening parentheses. The syntax coloring should show you the first one is pink in that long sequence of opening parentheses.

Doing it the more general way will make it easier to see if things are right. Define your list of countries e.g. as above use the variable name countrylist. Get the list of populations as above. Then make the list of country language fractions in a similar manner.

languagefractions=Map[Function[country,CountryData[country, "LanguagesFractions"], countrylist]

Then get the languages

languages=Apply[Union, languagefractions[[All,All,1]]];

Then get the number of language users in each country

users[population_, fractions_, language_]:= population*(language/.Append[fractions,_->0])

You could use Map or MapThread with Total, but maybe simpler to use Sum.

Map[Function[lang,lang->Sum[users[populations[[i]], languagefractions[[i]], lang], {i, 1, Length[countrylist]}]/Total[populations]],
languages]
POSTED BY: Todd Rowland
Posted 9 years ago
POSTED BY: John Cummings
Posted 10 years ago
POSTED BY: John Cummings

You have a syntax error with the parentheses in the last expression, too many closing parentheses in the wrong places.

The formula I wrote was a little misleading. When you have a bunch of things there are faster ways to do this, e.g.,

populations=Map[Function[country,QuantityMagnitude[CountryData[country, "Population"]]], countrylist]

will give the list of populations (see the documentation of the individual function names).

Then you could use other functions like Total, Sum, Table, and once you have a more succinct piece of code it will be easier to see if it's right.

POSTED BY: Todd Rowland
Posted 10 years ago

Hi Bruce

I think this is a Mathematica problem so I sent it to support@wolfram.com , I'm sure they'll pass it on if I've gone to the wrong place.

Cheers

John

POSTED BY: John Cummings
POSTED BY: Bruce Miller
Posted 10 years ago

Thanks very much Todd, I've emailed support

Cheers

John

POSTED BY: John Cummings

I see, yes that is strange. I don't know. You should send a comment to the Wolfram Alpha team, for one thing because the total percents it gives adds up to a little more than 100% even taking rounding into account. From a quick glance at the Wikipedia page, it seems there might not be a reliable number for this one.

POSTED BY: Todd Rowland
Posted 10 years ago

Hi Todd

Can I check that I have inputted this correctly? I had assumed one of the outputs was giving me a percentage of the total population who were speakers of each language but Wolfram Alpha tells me that only 60% of people in Angola speak Portuguese, Anguilla should barely effect this number of the total because it only has 15,000 inhabitants, none of which speak Portuguese.

https://www.wolframcloud.com/objects/68ba4fa3-0b9d-42bb-9916-6333910724ec

Could you explain what I'm seeing from the two outputs?

I'm sorry to keep asking questions

Thanks very much for your help

John

POSTED BY: John Cummings
POSTED BY: Todd Rowland
Posted 10 years ago
POSTED BY: John Cummings

Not sure how this would be done in Wolfram Alpha Pro, but it's not so hard in Wolfram Language. If you look at

http://reference.wolfram.com/language/ref/LanguageData.html

you can probably work it out, e.g. using the "CountryLanguageFractions" property.

To find the fraction over two countries, you might use the formula

average= ((average in X)(number in X) +(average in Y)(number in Y))/(X+Y)

which generalizes to a list of countries.

POSTED BY: Todd Rowland
Posted 10 years ago

For reference the set of countries are:

Angola, Anguilla, Antigua, Bangladesh, Botswana, British Virgin Islands, Burundi, Cameroon, Cayman Islands, Democratic Republic of Congo, East Timor, El Salvador, Ghana, Haiti, India, Indonesia, Ivory Coast, Jamaica, Jordan, Kazakhstan, Kenya, Kosovo, Kyrgyzstan, Madagascar, Malaysia, Mongolia, Montenegro, Morocco, Myanmar, Nepal, Niger, Nigeria, Pakistan, Panama, Philippines, Russia, Rwanda, Saudi Arabia, South Africa, Sri Lanka, St Kitts, Suriname, Tajikistan, Thailand, Tobago, Trinidad, Tunisia, Turks and Caicos Islands, Uganda and Ukraine

POSTED BY: John Cummings
Posted 10 years ago

Hi Nasser

Many thanks but that's not quite right, I'm not looking for the most common language per country, I'm looking for the most common languages for the sum total population of a set of countries.

Thanks

John

POSTED BY: John Cummings
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract