Had a spot of trouble working with matplotlib on Pycharm. The
YouTube video below saved the situation. As well, Pycharm
refuses matplotlib.use('Agg'). (This uses a newer ersion of matplotlib.)
Had a spot of trouble working with matplotlib on Pycharm. The
YouTube video below saved the situation. As well, Pycharm
refuses matplotlib.use('Agg'). (This uses a newer ersion of matplotlib.)
* * *
Using logical operators to do bitwise operations can
have surprising outcomes.
10 0000 1010
4 0000 0100
Thus, 10 and 4 have no aligned 1s, and the return on 10 & 4 is 0.
Had I asked for 10 & -4, two's complement would have kicked in:
-4 1111 1011 for the flip to complement
1111 1100 to two's complement
0000 1000 which is a return of 8
I have long heard that computers subtract by addition.
It's actually rather clever. The most significant bit (in a signed number), on
the left, is the sign of the number: 0 iindicates a positive number,
1 a negative. So if the second (negative) number in our operation
is greater than the first (positive) one, the 0 flips to 1 and one has
a negative value.
So why do we say that it is subtraction through addition: because one is
adding a positive number and a negative one, rather then subtracting
a positive from a positive. This magic works as we flip the second number,
transforming a small positive number into a lage negative one. ie
a simple 8-bit binary number represents numbers of 0 to 255, while a flipped
number goes from 0 to 127 in the positive and 0 to -127 for the negative.
Problem here, 0 and -0 have different representations. Adding 1 to the
flip solves the problem. One then subtracts by addition with no problem.
Two's complement is standard for most computers. Below, (4 - 1).
0000 0100
1111 1111
________
0000 0011
So essentially, the machine just adds 0s and 1s, which we can emulate
using the normal rules of addition ie with a carry-over!!
Interesting site:
Binary and Decimal Numbers - AndyBargh.com
Of course, the two pear images are of the same color.
* * *
A photo Lyse recently took, from Banff:
The May to May inflation numbers are coming out this morning, and
it's going to be bad: I've seen, 7.4% suggested because transportation
costs are going up. Taking a bit of perspective, I compute, below, inflation
going back three years, giving a yearly average of...3.3%:
Fine, I'm blabbering...Let's wait!
* * *
7.7% for Canada, 7.5% for Quebec.
* * *
This is how income programs for Seniors are indexed. The 'Rentes du Quebec'
follows the same calculations as the CPP, from November Year 1 to October Year 2.
With changes applied from January. OAS/GIS gets adjusted on a quarterly basis,
with the annual re-set in July. (Benefit levels vary with amounts received from
private income, including CPP).
First day of astronomical summer, and longest day of the year, with -
at this latitude - 15 hours and 40 seconds of daylight!
Mathplotlib forPython is really easy to use, and can create quite
awesome little visuals. Below, 6 months of inflationdata from the
Bank of Canada:
Working from W3Schools Mathplotlib interface...
I say it's a good thing: France's Macron government is short
39 votes out of 577 to govern with a majority, and thus needs
to ally itself with another parliamentary group to pass anything.
Many will opine that it is democracy in action, forcing hard work
and compromise. Have your say! What I like about it is that the
shortfall is so slim that the government can do pretty much anything
and the votes are there for it. It can leave the EU with the Rassemblement
National, curb immigration with Les Républicains, ban anything that belches
from the roads with the Nupes. And spend on things military with any
number of partners. Things look daunting this morning, but in these
troubled times, it makes the government adaptable.
A particularity of recent French elections is the low participation rate. Young people
in particular shun elections with a blasé 'what difference can it make'. This
is not apathy; these same young poeple, who will only vote if the vote is 'crucial',
think nothing of going to the streets, shutting down schools and other direct action.
Indeed, the 2017 election saw the appearance of J-L Mélenchon's 'La France
Insoumise' - ('Disobedient France') - was a clear appeal to this population.
Followed by the creation of Macron's 'En Marche' - (Advancing together) - which has
governed since then. And in a show of great consideration, Mélenchon himself
(71 years old) did not seek a seat for himself, while still leading his coalition to substantive
gains!!
So in my usual vein, as someone watching foreign elections from afar, Congratulations
to All on this election!!
source: Le FigaroA little Python reminder: the print command has to be used for
a result to be shown on the screen as such. The return statement
merely stores something in memory. One needs to create a variable
whose name goes in the print command...
The import 'math statement' at the beginning gives access to the math library
of pre-defined functions.
* * *
I remember this from high school physics: all metals expand in the heat, as
a functio of length ofobject and degree of heat:
Had occasion to look up 'Baltic cocktail', and eneded up
on the urban dictionary. Hey, it's the week-end...
* * *
As an example, I invest in a 10 year bond which pays 3% per year cumulatively.
At the same time, I project inflation to be running at 2% annually. Waht is the
discounted return of my investment:
is all tied up for ten years. It's all in what one wants...
* * *
Below, discounting GDP figures. Real GDP - as opposed to nominal - takes inflation
into account.
depreciated assets!?)
* * *
Working with Python on the Idle interface, one can output yearly numbers
from a formula:
This is enigmatic: Python and my Windows calculator start showing different numbers
after a while. Both my Mac and an Android tablet wisely stopped short of giving
that many decimals: