Using Google REST API for Analytics

If you are not a Google Engineer, OAuth2 for Google APIs can be a nightmare without good examples.  If you think Facebook was bad at providing instructions, wait to get lost in a Microsoft-style ocean of useless information provided by Google on its new V3 gdata….

I assume you have curl installed, and here is a step-by-step guide on how to retrieve Google Analytics data using curl, which for me remains the best way to test any API.

  1. Visit Core Reporting API, and get confused by the amount of (not very useful) information ;
  2. On your browser, log-in at Google with the account you want to use to access Analytics info;
  3. Go to the APIs console. Click on create a “project”. Put “status on” for Analytics. Possibly rename the project going to the left menu “API Project” –the name given by default to the project;
  4. Click on “API Access”. Click on “Create an OAuth 2.0 client ID”. Give any name (this name is the one which would be seen by users, but here the only user will be you, downloading your data). Chose “Installed Application” and then “Create ID”. These infos will appear:Client ID for installed applications
    Client ID:
    1234567890.apps.googleusercontent.com
    Client secret:
    xywzxywzxywzxywzxywz
    Redirect URIs: urn:ietf:wg:oauth:2.0:oob

    http://localhost

  5. Go to Using OAuth 2.0 for Installed Apps (hardly useful), form the following URL and visit it with the browser where you logged in with your Analytics account (I had to guess the scope, could not find a page where all scope values are listed!):
    https://accounts.google.com/o/oauth2/auth?
    scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fanalytics&
    redirect_uri=urn:ietf:wg:oauth:2.0:oob&
    response_type=code&
    client_id=1234567890.apps.googleusercontent.com
  6. Allow the access, of course, and copy the code which should look like
  7. Go to the terminal and use the command below using your own “code” from above, “client_id” etc:
    curl  -H "Content-Type: application/x-www-form-urlencoded"
    -d 'code=4/v6xr77ewYqjkslsdUOKwAzu
    &client_id=1234567890.apps.googleusercontent.com
    &client_secret=xywzxywzxywzxywzxywz
    &redirect_uri=urn:ietf:wg:oauth:2.0:oob
    &grant_type=authorization_code'
    
    https://accounts.google.com/o/oauth2/token
  8. You’ll get a JSON like this one:
    {
      "access_token" : "ya29.AHES6Zkjhkjhahskjhskkskjh",
      "token_type" : "Bearer",
      "expires_in" : 3600,
      "refresh_token" : "1/HH9E7k5D0jakjhsd7askdjh7899a8sd989"
    }
  9. If you curl:
    curl 'https://www.googleapis.com/oauth2/v1/tokeninfo?
    access_token=ya29.AHES6Zkjhkjhahskjhskkskjh'

    you’ll get something like:

    {
     "issued_to": "562211803675.apps.googleusercontent.com",
     "audience": "562211803675.apps.googleusercontent.com",
     "scope": "https://www.googleapis.com/auth/analytics",
     "expires_in": 3556
    }

    (see below how to renew the token without having to go to ask for another “code” as in point 5)

  10. Done
    curl 'https://www.googleapis.com/analytics/v3/management/
    accounts?access_token=ya29.AHES6Zkjhkjhahskjhskkskjh'

    will give you all info about your accounts, more info on the Management API REST page.

  11. How to get the data? A nice hint I could not find anywhere is that the URL of the new Analytics Dashboard provides account, web property and profile:
    https://google.com/analytics/web/#dashboard/default/
    aACCOUNTwWEBPROPERTYpPROFILE/
  12. Which means you can get the data with the following address:
    curl 'https://www.googleapis.com/analytics/v3/data/ga?
    ids=ga:PROFILE&metrics=ga:visits&start-date=2011-12-01&
    end-date=2011-12-08&
    access_token=ya29.AHES6Zkjhkjhahskjhskkskjh'

Renew the token

You have to use the “refresh_token” received in point 8:

curl -d "client_id=562211803675.apps.googleusercontent.com
&client_secret=ZQxoOBGbvMGnZOYUrVIDXrgl
&refresh_token=1/HH9E7k5D0jakjhsd7askdjh7899a8sd989
&grant_type=refresh_token" 

https://accounts.google.com/o/oauth2/token

and you’ll get a new access_token.

Posted in Informatics | Tagged , | Leave a comment

aNobii: virtual libraries and actual sales

This post was inspired by “ aNobii Library and copies sold“ (in Italian), by jumpinshark. I do also enjoy scraping various sites,  aNobii included before they hired me:), and I think that looking from the outside one often has ideas that would otherwise struggle to emerge from the inside. The idea that not all books have the same ratio sales / presence-in-aNobii-libraries is indeed interesting: some books are extremely successful on aNobii but don’t sell much, others the other way around. So I could not resist using some probability distributions and see if I could generalise the results obtained by jumpinshark. Note that I did not use any internal aNobii data for this.

Unique aNobii visitors in Italy

Before starting, however, I must underline that there was no drop in the number of unique visitors we had (contrary to  what DoubleClick estimates, as reported by jumpinshark). Even in Italy, we never dropped below 30.000 unique visits per day and we are still (very well!) above 70,000 per month. Above you can find the graph taken from Google Analytics, without numbers, which shows unique visitors per month in Italy during the past twelve months: it’s constant.

That said, let’s go back to jumpinshark. As mentioned, his analysis is correct, and may be further formalized, using distributions instead of averages.

The analysis –a little more formal

You can find on this Google Spreadsheet all results. Let’s list the assumptions:

  1. The distribution of numbers of books purchased per year is a Pareto-Zipf with exponent 2: If I have 100 people in Italy who have bought 1 book, I’ll have 100 / 2 ^ 2 which have bought 2, 100 / 3 ^ 2 which I have bought 3 etc. See Column B of the spreadsheet. (With this distribution, strong readers who read 10 books a year are more than ~ 2 million).
  2. It is n times more likely that a person with n books joins aNobii than a person with 1 book. See column C.
  3. Each book has its “resonant reader.” For example, I assume that the “resonant” readers for Umberto Eco buy 15 books a year (kind of intellectual), readers of Benedetta Parodi (TV show lady) read just 1 book per year . I say “resonant” because usually in these cases one uses the Cauchy distribution, which is used in physics precisely for resonances. Resonant does not mean exclusive: other readers might like Eco and Parodi, only a bit less. See column D & E and cell G9, H9.

End of assumptions. The distributions above are quite standard in these cases, and show that when an author resonates with avid readers, like Eco does, s/he has a better chance of appearing on aNobii than a more pop book with same amount of sales. This stems from the fact that a voracious reader is more likely to end up on aNobii, although there are many members of aNobii with very few books in the library, just as in the hypothesized distribution.

So for every aNobii-user who owns Eco, there are about 230 people on the street that have actually bought it. For Ms Parodi the ratio is 1 to 1000 instead. Still, as noted by jumpinshark, there are other factors: I bet that “ aNobii, the reading worm“, a book composed by aNobii reviews, has a ratio close to 1:) Anyway, even if the numbers are far from perfect, the result is not bad, IMHO….

Posted in Articles | Leave a comment

Librerie virtuali di aNobii e vendite reali

Questo post è stato ispirato a “Libreria aNobii e copie vendute“, di jumpinshark. Anche io mi diverto a fare scraping di siti vari, aNobii incluso prima che ci finissi a lavorare:), e credo che guardando dall’esterno spesso si abbiano idee che dall’interno fanno fatica a emergere. L’idea che non tutti i libri abbiano lo stesso rapporto vendite/posseduto da aNobiani per esempio è verissima –e non ho resistito a vedere se usando un po’ di distribuzioni di probabilità potevo ottenere il risultato di jumpinshark (anche io senza usare dati interni di aNobii!).


Visitatori Unici/Mese in Italia

Prima di iniziare però devo assicurare che, grazie a dio, non c’è stato un calo sensibile di visitatori unici ad aNobii. Anche in Italia, non siamo mai scesi sotto i 30,000 unici/giorno e siamo ben (molto ben!) al di sopra di 70,000 al mese. Non è il cuore del post, ma metto affianco il grafico preso da GAnalytics, senza numeri, che mostra che gli utenti unici /mese di aNobii in Italia nell’ultimo anno son sempre lì.

Detto questo, torniamo a jumpinshark. Come detto, l’analisi secondo me è giusta, e può anzi essere formalizzata ulteriormente, usando distribuzioni al posto delle medie.

Analisi un po’ più formale

Trovate su questo Google Spreadsheet tutti i risultati. Ma siccome gli spreadsheet son difficili da seguire, partiamo dall’inizio con le ipotesi di partenza:

  1. La distribuzione dei numeri di libri comprati all’anno è la Pareto-Zipf con esponente 2: se ho 100 persone in Italia che han comprato 1 libro, ne avrò 100/2^2 che ne hanno comprati 2, 100/3^2 che ne hanno comprati 3 etc. Cfr colonna B dello spreadsheet. (Con questa distribuzione i lettori forti che leggono più di 10 libri all’anno sono ~2 milioni).
  2. È n volte più probabile che una persona con n libri venga ad aNobii rispetto ad una persona con 1 libro. Cfr colonna C.
  3. Ogni libro ha il suo “lettore risonante”. Per esempio ho ipotizzato che il lettore “risonante” di Eco compri 15 libri all’anno, quello della Parodi 1. Dico “risonante” perché normalmente in questi casi uso la distribuzione di Cauchy, usata appunto per le risonanze. Risonante non vuol dire esclusivo: anche agli altri lettori Eco e Parodi piacciono, solo piacciono meno. Cfr colonna D&E e celle G9, H9.

Fine delle ipotesi. Le distribuzioni usate sono abbastanza standard in questi casi, e mostrano che quando uno scrittore risuona con lettori accaniti, come Eco, ha una maggiore probabilità di apparire su aNobii in rapporto al numero delle vendite rispetto ad uno scrittore che risuona con lettori occasionali. Questo deriva dal fatto che un lettore accanito ha più probabilità di finire su aNobii, nonostante su aNobii ci siano molti iscritti con pochissimi libri in libreria, esattamente come nella distribuzione ipotizzata.

Quindi per ogni aNobiano che possiede Eco ci sono ~230 lettori che l’hanno effettivamente comprato. Per la Parodi il rapporto invece è 1 a 1000. Detto questo, come fatto notare da jumpinshark, ci son altri fattori: scommetto che “aNobii, il tarlo della lettura” ha un rapporto vicino a 1:) Comunque, anche se i numeri son lungi dall’essere perfetti, ci siamo no?

Posted in Articles | 1 Comment

Fantacalcio Bayesiano

Mi è stato detto che la chiave del fantacalcio (a cui non ho mai giocato) è quella di individuare quale calciatore effettivamente scenderà in campo la domenica. O si tira a caso, oppure ci si informa sulle varie testate sportive –e poi si tira a caso.

Qual è la probabilità che un calciatore, diciamo Pippo, scenderà in campo dato che un certo numero di testate lo danno per favorito?

Non lo so, ma è un buon esempio per vedere come funzionano la “interpretazione logica della probabilità” di Richard Cox. Come dice Wikipedia: “As the laws of probability derived by Cox’s theorem are applicable to any proposition, logical probability is a type of Bayesian probability.”

Introduciamo due assiomi. Immaginiamo che il lunedì pensiamo alla partita di domenica prossima, e che la Gazzetta pubblichi le probabili formazioni il giovedì:

  1. Se possiamo dire quanto crediamo che Pippo giocherà domenica prossima, possiamo anche dire quanto crediamo che Pippo non giocherà. Banale.
  2. Se possiamo dire quanto crediamo che giovedì la Gazzetta dirà che Pippo giocherà, e possiamo dire quanto crediamo che Pippo giocherà quando la Gazzetta lo dà giocatore, allora possiamo anche dire quanto crediamo (il lunedì) che domenica sera avremo avuto sia Pippo in campo la mattina, sia Pippo nella probabile formazione della Gazzetta il sabato prima. In altre parole: se conosco la Gazzetta, conosco Pippo.

Con questi due assiomi possiamo scrivere due  formule, che mappano i nostri “quanto crediamo che….” con numeri reali positivi. Tipo: “su una scala da 0 a 20 la probabilità che Pippo giochi secondo me è 18″ vuol dire che sono abbastanza convinto che Pippo giocherà. In probabilità, normalmente, invece di una scala da 0 a 20 si usa una scala da 0 a 1, ma è pura convenzione. Le formule:

La probabilità che pippo giochi date certe informazoni più la probabilità che pippo non giochi, date le stesse informazioni, è uguale a 1 –la crediamo sempre vera:

(1) prob(gioca | info) +prob(non gioca | info) = 1

La probabità che domenica sera ci si ritrovi con Pippo che è stato in campo e con la Gazzetta che sabato lo aveva messo nella probabile formazione è uguale alla probabilità che Pippo giochi quando la Gazzetta lo mette in formazione, per la probabilità che la Gazzetta lo metta in formazione:

(2)     prob(gioco, in_formazione | info) =
prob(gioco | in_formazione, info) • prob(in_formazione, info)

Dove la virgola “,” vuol dire “e allo stesso tempo”, la barra “|” vuol dire “dato”, e il punto “•” vuol dire “moltiplicato per”.

La cosa importante da capire è che quando diciamo “probabilità” intendiamo “quanto fortemente credo che”. Probabilità 90% non vuol dire che testando il modello cento milioni di volte la mia ipotesi si avvera 90 milioni di volte. La probabilità che Pippo giocherà è data da vari fattori, come lo stato della sua forma fisica, la squadra avversaria e la formazione conseguentemente scelta dall’allenatore etc etc. Su questa base, e solo su questa, io devo stimare la probabilità che Pippo giocherà. Ma siccome sono pigro faccio fare questo lavoro alla Gazzetta e uso la sua stima per la mia fanta-formazione.

Teorema di Bayes

Le due formule sopra sono la base su cui costruire un algebra delle probabilità. La prima formula da ottenere è il teorema di Bayes. Definiamo:

G: Pippo gioca
F: La Gazzetta lo mette nella probabile formazione
I: Informazioni varie sullo stato fisico di Pippo etc etc

Possiamo quindi scrivere:

(3)     prob(G| F, I) = prob(F | G, I) • prob(G, I) / prob(F | I)

La formula (3) deriva direttamente dalla (2) con F e G intercambiati:

(2′)     prob(F, G | I) = prob(F | G, I) • prob(G | I)

Poiché la probabilità che “F e G siano vere domenica sera” è uguale alla probabilità che “G e F siano vere domenica sera”, ossia prob(F, G | I)=prob(G, F | I), possiamo eguagliare i secondi termini delle formule (2) e (2′) e ottenere (3).

Marginalizzazione

La seconda formula è la formula di marginalizzazione. Consideriamo che:

(4)   prob(G | I) = prob(G, F | I) + prob(G, notF | I)

La (4) ci dice che la probabilità che Pippo giochi è uguale alla probabilità che Pippo giochi e la Gazzetta lo metta in formazione più la probabilità che Pippo giochi e la Gazzetta non lo metta in formazione. Ovvio.

Ora, immaginiamo che invece di guardare solo la Gazzetta noi saggiamente andiamo a guardare 5 giornali sportivi. Ognuno di questi giornali metterà o meno Pippo nella sua probabile formazione: abbiamo 32 possibili combinazioni, da 0, 0, 0, 0, 0 (nessun giornale mette Pippo in formazione) a 1, 1, 1, 1, 1 (tutti i giornali mettono Pippo in formazione). Ognuna di queste 32 combinazioni che chiamiamo F1, F2, F3…. F32 è mutuamente esclusiva, ossia solo una può essere vera. Aggiungiamo anche che almeno una deve essere vera: queste sono tutte le combinazioni possibili. Quindi possiamo scrivere:

(5)    prob(G | I) =
prob(G, F1 | I) + prob(G, F2 | I) + …. + prob(G, F32 | I)

Siccome abbiamo detto che le F1…F32 sono mutualmente esclusive, la (5) è ovvia quanto la (4): la probabilità che Pippo giochi è uguale alla probabilità che giochi dopo che nessun giornale lo abbia messo in formazione, più la probabilità che giochi dopo che solo uno dei cinque giornali lo abbia messo in formazione, e così via.


Tutto questo non aiuta, ancora, a prevedere se Pippo giocherà o no, ma secondo me insegna qualcosa: guardate pure le probabili formazioni dei giornali, ma metteteci del vostro. Siate voi gli esperti capaci di prevedere se un giocatore giocherà o meno, a prescindere da quello che dicono i giornali….

Posted in Articles | Leave a comment

Distribution of Price on the Apple Application Store

Once iOS publishers have developed their application, paid $100 for having it distributed on the Apple App Store, gone through the long approval process, they finally have to chose a price.

But before chosing a price, they could ask themselves:

“How did my competitors price their applications?”

This is really important. If 99% of the competitors priced above $4.99, you might set your price at $3.99, and potential buyers would be happy to buy from you (for the time being, we do not take quality in consideration.)

The ubiquitous Gaussian, bell-shaped curve is of no use in the realm of prices: There is nothing like a bell shaped price distribution. The chart below shows how the prices of 172,083 applications sold on the Apple App Store are distributed (if you wonder how to scrape this information from iTunes, have a look at this article):

About 85,000 applications are priced at $0.99. The number of applications priced $1.99 is approximately 1/4 of those priced $0.99. The ones at $2.99 are approximately 1/9, and so on. In other words, the number of applications sold at a certain price looks inversely proportional to the price squared. (If you want to know more about power law distributions, see the Pareto-Zipf-Mandelbrot distribution on Wikipedia).
Power law distributions are better displayed on a logarithm-logarithm scale*, i.e. plotting the logarithm of the number of applications versus the logarithm of their price. The logarithmic-logarithmic plot of the distribution of prices on the Apple App Store looks like this:

A few points are placed close to a straight line: These points correspond to the number of applications sold at 1$ and multiples of 5$ (one cent is almost always subtracted to the round price: actual prices are 0.99$, 4.99$, 9.99$ etc). Interestingly, the number of application selling for odd prices, like, for example, $7.00, is much lower then the number of application selling for $4.99 or $9.99. Therefore the point corresponding to $6.99 lies well below the straight line.Although prices can be freely chosen, most sellers price their application at multiple of $5 (minus 1 cent).

Let us imagine a publisher of a very innovative application, which, at launch, has no competitors. The marketing manager tries different prices, and notices that two prices generate the highest revenues: $3.99 and $4.99. When the price is $3.99, the publisher sells 50 units a day, while 40 units are sold if the price is $4.99. The total revenue is $200 a day in both cases. So, if there is no competition, both prices will do.

As we know, competition is alert and after a few months, other publishers enter the market with similar applications, which are also priced at $3.99 or $4.99. A few months later, the publisher discovers that 90% of the competitors prefer, for some reason, to price their application at $4.99, and only 10% at $3.99. By setting the price to $3.99, our publisher can price-differentiate its product and confront less competition.

The take-home message is the following: By analyzing the distribution of prices, it is possible to spot price regions that are relatively empty, that’s what we call “price-gaps”. Price gaps offer the possibility to diversify a product by setting its price in an uncommon range. In a market where competition is hard, a handful of cents can make the difference. Our simple analysis provides a reference pricing on which to base marketing decisions.

* Notes:
Creative Commons License
Posted in Informatics, iphone | Leave a comment

AAA Comune Milano Cerca Esperto Derivati?


“Dopo una vita di risparmi, di BOT e CCT, devo proprio riposarmi, andare via di qui”. Ma erano gli anni ’80. Venti anni dopo i Figli di Budda canterebbero a suon di swap, future, CDO e CDS. Nel 2005 l’associazione bancaria italiana, ABI, annuciava che “831 enti locali anno avuto accesso a strumenti derivati”, ossia prodotti finanziari il cui valore deriva dal valore di un bene sottostante (azioni, tassi di interesse, cambi monetari, prezzi degli immobili). BOT e CCT non vanno più. Associata all’acquisto di derivati da parte degli enti c’era una possibile perdita (da parte di questi e di piccole e medie imprese) di 4 miliardi di euro, ma, rassicurava il direttore dell’ABI Domenico Santacecca alla commissione finanze della Camera sui derivati: “La perdita è solo potenziale, non è assolutamente certo che alla scadenza delle operazioni questo importo corrisponderà a quanto effettivamente a carico delle imprese [e degli enti].”


In quello stesso momento, a Londra, i rappresentanti del comune di Milano firmavano contratti per 1.6 miliardi di euro con quattro banche d’affari: Deutsche Bank, Ubs, Depfa Bank, JP Morgan. Quattro anni dopo, a seguito di un’inchiesta che vedrà l’arresto di dieci banchieri delle suddette banche insieme a dipendenti e consulenti del comune, l’allora direttore generale della tesoreria di Milano affermerà, ricordando la firma dei contratti: “Non sono in grado di interloquire in lingua inglese e non sono affatto un esperto in operazioni in strumenti derivati.”

 

Non stiamo parlando della solita Canicattì. Stiamo parlando di Milano, l’equivalente italiano di Londra, la cui amministrazione comunale si fa, come scritto nell’inchiesta del PM Alfredo Robledo, “spogliare dolosamente” da una decina di banchieri. Un comune i cui rappresentanti o non parlano inglese e nulla affatto sanno di derivati, oppure sono solo molto desiderosi di firmare –e finiscono indagati.

 

Da quattro anni a questa parte qualcosa, per fortuna, è cambiato. Il pericolo dell’abuso dei derivati è stato recepito dal legislatore. La legge finanziaria del 2008 introduce l’idea che un ente pubblico è come un comune cittadino, e quindi la banca deve assicurarsi che l’acquirente abbia “preso piena conoscenza dei rischi e delle caratteristiche dei medesimi [derivati]“, pena indagini e annullamenti di contratti. Anche la Corte dei Conti nel frattempo compirà varie “indagini sul fenomeno degli strumenti derivati finanziari” negli enti locali.

 

Ma sono tutti uguali questi enti locali? Se la capitale della finanza italiana si è fatta abbindolare come un bambino goloso, è accaduto lo stesso per tutti gli altri comuni? Per fortuna no…

Posted in italia | Leave a comment

GAS: i saldi arrivano per decreto

GAS: I SALDI ARRIVANO PER DECRETO

di Mario Alemi e Alberto Cavaliere 24.07.2009

Il decreto “anticrisi” contiene un articolo dal titolo “Riduzione del costo dell’energia per imprese e famiglie” e riguarda la riduzione pilotata dei prezzi del gas. (1) Secondo molti addetti ai lavori il decreto non sarà che un favore all’Eni e ad alcuni settori industriali. L’associazione dei grossisti italiani dell’energia (Aiget) ha fatto sapere che aspetterà “di vedere come il decreto sarà attuato, ma che al momento non sembra un passo avanti verso la liberalizzazione del mercato”.

Posted in Articoli, italia | Leave a comment

Installing OpenFVM on Darwin (Mac OS X)

openfvm-fluidYes. After many, many years I went back to GNU compilers and linkers

Let’s say you want to simulate a fluid, and how it is heated by a hot cylinder.

What do you do? You take a hot cylinder and measure the lost of heat. But if you don’t want to mess around with hot cylinders and water, and you have a Mac (or even better Linux) you can install a simulation software and reproduce your experiment in the computer.

OpenFVM is such an application, and is opensource. It is easy to use, but must be compiled to be installed. That’s pretty easy on Linux, no idea about Windows, and decently easy on Mac. Here are some advices for Mac users.

Developers’ tool

First of all, you must install either Apple developer tools or fink. Apple’s tools have a huge amount of useless stuff (like XCode), where fink is fantastic, because it creates a similar environment of a debian machine. For example, you can search if there is a package ready to be used with:

apt-cache search package_name

and then install it with

apt-get install package_name

NB as root, you have to add the following line to your .profile file:

test -r /sw/bin/init.sh && ./sw/bin/init.sh

Installation of GMSH

You could download the GMSH libraries from http://www.geuz.org/gmsh, but you would not have the possibility to use (easily) the command line. Then, it is much better to build them.

Download the source code. Untar it and go into the directory gmsh-version_number. Run ./configure. You’ll probably get an error:

configure: error: Could not find GSL, aborting.

If so, you have to install the Gnu Scientific Libraries. Then:

apt-get install gsl

If the linker (ld) shows some problem, you probably also have to add the directory where fink put all libraries to the LDFLAFS environment variable. Add in the makefile:

export LDFLAFS=-L/sw/lib/ 

or in your .profile

export DYLD_LIBRARY_PATH=/sw/lib/ 

But this might be not enough. If you receive an error message about a missing libjpeg library you have to create a link in /sw/lib:ln -s /sw/lib/libjpeg.62.dylib /sw/lib/libjpeg.dylib

Compiling OpenFVM

Before following the instruction you find on the OpenFVM page on how to compile all the stuff, go into Flow/serial/laspack and edit eigenval.c. Comment out the line #ifdef __linux__ like that:

//#ifdef __linux__

#define max(x, y) ((x) > (y) ? (x) : (y))

#define min(x, y) ((x) < (y) ? (x) : (y))

//#endif

After having built the laspack libraries, run make in the Flow/serial directory.You will get the following error:

source/main.c:24:20: error: malloc.h: No such file or directory

Here, you have to edit main.c, setup.c, reorder.c and change#include <malloc.h> in#include <sys/malloc.h>.

Now compile. If you get the following error:

Undefined symbols:

"_max", referenced from:_EstimEigenvals in liblaspack.a(eigenval.o)

"_min", referenced from: _EstimEigenvals in liblaspack.a(eigenval.o)

it means you have not edited eigenval.c in the Flow/serial/laspack directory.

Posted in Informatics | 1 Comment

Google Friends etc….

With Google Friends, you “add social features to your site”. Whatever that means!

GF is an application based on Opensocial . Opensocial is a standard for having the same application working on different social network sites. The simplest feature, for instance, is that you can log in with your Yahoo/Google/MySpace/LinkedIn (and others) account. You could build a stupid application showing all your friends. If you put this application on MySpace or visualab.org, well, it will work the same!

If you “join” visualab.org (the button on the right) (yes, just underneath “Google Friends”), you won’t get anything because I have no time to set up a social network website, but well, that could be a terrific investment. It is like if you bought one IBM share in the 1960s… for free.

And I’m not going to ask Bill Gates to write an operating system!

Posted in Articles, Informatics | Leave a comment

Making money with water –Quantum of solace

Waterdrop on a feather by Tanakawho (flickr)Finally, an enlightened and perverse mind has found the way to become shamefully rich in the water industry. After three months in the US, interviewing executives and analysts from the water industry, I begun wondering if there was anybody out there happy with what so many people call “the blue gold”.

Really, is there anybody getting rich, shamefully rich, with water? YES!

Dominic Greene, CEO of Greene & Co., will apparently provide water to the whole country of Bolivia, after having negotiated an increase of 100% in tariffs.

With water tariffs in Bolivia ranging between 2.01 and 7.28 Bolivianos/m3 (0.25 and 0.95 USD/m3, 2005 data) and average water use for domestic consumption of 55 litres/day (1987 data), Mr Green will rake up more than $55m, before tax, as we can assume he will not invest a single Boliviano in new infrastructures.

Water Street Unfortunately for him, after having bribed the newly installed dictator with an aluminium case full of dollar bills, he will eventually be left, alone and without water, in the Andean highlands by an agent on Her Majesty’s Secret Service, James Bond. Mr Green will eventually be executed by his former partners.

PS James Bond may be a fictional character, but Bolivian tariffs and consumption data I used are not. Cfr. www.earthtrends.org/gsearch.php?va=cp&kw=bolivia&theme=0 and www.sisab.gov.bo/sisab2/sisab/documentos/INDICADORES2005.pdf

Posted in media, World | Leave a comment