text:
ISSN 0439-755X
CN 11-1911/B

Acta Psychologica Sinica ›› 2017, Vol. 49 ›› Issue (1): 40-49.

### Childhood maltreatment and depression: A Meta-Analysis

YU Zengyan1; ZHAO Ameng1; LIU Aishu2

1. (1 College of Mental Health, Qiqihar Medical University, Qiqihar 161006, China) (2 College of Educational Science, Harbin Normal University, Harbin 150025, China)
• Received:2016-03-11 Published:2017-01-25 Online:2017-01-25
• Contact: YU Zengyan, E-mail: yuzengyan@163.com

Abstract:

Childhood maltreatment is closely correlated with depression but only a few studies have examined the specific effects of various types of childhood abuse on depression. Moreover, the comparability of previous research is seriously limited because a high level of heterogeneity can be observed across the published studies. This meta-analysis was to estimate the association between depression and different types of childhood maltreatment (psychological abuse and neglect, sexual abuse, physical abuse and neglect). A systematic review was conducted to study the relationship between subtype of childhood maltreatment and depression. A total of 92 independent effect sizes (31 studies, 24283 participants) were found within the criteria of the meta-analysis. After coding the data, independent effect sizes were analyzed by CMA 3.0 program. Odd ratios and 95 % CI of effect sizes were calculated by using random-effects model. Four items including heterogeneity test, publication bias test, main effects analysis and moderation effect were analyzed. There was a significant heterogeneity in 92 independent effect sizes in heterogeneity, and the random-effects model was an appropriate model for subsequent meta-analyses. The impact of publication bias was modest and the major finding still remained valid. The research revealed a robust association between childhood maltreatment and depression (OR = 2.84, 95% CI: 2.45 – 3.29). In addition, the meta-analyses for each type of maltreatment revealed that psychological abuse (OR = 3.58, 95%CI 2.87 – 4.48) and emotional neglect (OR = 3.24, 95%CI 2.43 – 4.32) were most strongly associated with the outcome of depression. The analysis revealed that the participant’s age and sex could affect the relationship between childhood maltreatment and depression. This meta-analysis addressed the different effects of sub-types for childhood maltreatment on depression. The findings implied that childhood maltreatment was a genuine risk factor for depression, especially highlighting the potential impact of the more “silent” types of childhood maltreatment on the development of depression. Moreover, our findings raise our awareness for the potential needs of adolescents or women who were formerly exposed to childhood abuse. This is important to prevent their depression and is thus a general public health issue. Clinicians also have to be aware of the importance of early childhood experiences to better meet the needs of their patients.


text:
# find orthogonal eigenvectors

The nullspace is projected to zero. We ï¬rst deï¬ne the projection operator. Some things to remember about eigenvalues: â¢Eigenvalues can have zero value 6.4 Gram-Schmidt Process Given a set of linearly independent vectors, it is often useful to convert them into an orthonormal set of vectors. Learn to find complex eigenvalues and eigenvectors of a matrix. where ð is a matrix of eigenvectors (each column is an eigenvector) and ð is a diagonal matrix with eigenvalues ðð in the decreasing order on the diagonal. When we have antisymmetric matrices, we get into complex numbers. which are mutually orthogonal. Recall some basic de nitions. The reason why eigenvectors corresponding to distinct eigenvalues of a symmetric matrix must be orthogonal is actually quite simple. Find the eigenvectors and values for the following matrix. Find all the eigenvalues and corresponding eigenvectors of the given 3 by 3 matrix A. Let ~u and ~v be two vectors. then the characteristic equation is . The dot product of eigenvectors $\mathbf{v}_1$ and $\mathbf{v}_2$ is zero (the number above is very close to zero and is due to rounding errors in the computations) and so they are orthogonalâ¦ We must find two eigenvectors for k=-1 â¦ and solve. If you can't do it I will post a proof later. The vectors shown are the eigenvectors of the covariance matrix scaled by the square root of the corresponding eigenvalue, and shifted so â¦ In fact, for a general normal matrix which has degenerate eigenvalues, we can always find a set of orthogonal eigenvectors as well. Note that we have listed k=-1 twice since it is a double root. If A is unitary then the eigenvectors of A, belonging to distinct eigenvalues are orthogonal. The eigenvectors for D 0 (which means Px D 0x/ ï¬ll up the nullspace. Diagonalize the matrix. The only eigenvalues of a projection matrix are 0 and 1. Statement. First one was the Characteristic polynomial calculator, which produces characteristic equation suitable for further processing. We will now need to find the eigenvectors for each of these. And even better, we know how to actually find them. The column space projects onto itself. If v is an eigenvector for AT and if w This is an elementary (yet important) fact in matrix analysis. FINDING EIGENVALUES AND EIGENVECTORS EXAMPLE 1: Find the eigenvalues and eigenvectors of the matrix A = 1 â3 3 3 â5 3 6 â6 4 . by Marco Taboga, PhD. Recipe: find a basis for the Î»-eigenspace. But even with repeated eigenvalue, this is still true for a symmetric matrix. Perturb symmetrically, and in such a way that equal eigenvalues become unequal (or enough do that we can get an orthogonal set of eigenvectors). Let be two different eigenvalues of .Let be the two eigenvectors of corresponding to the two eigenvalues and , respectively.. Then the following is true: Here denotes the usual inner product of two vectors . Both are not hard to prove. If . Question: Find A Symmetric 3 3 Matrix With Eigenvalues Î»1, Î»2, And Î»3 And Corresponding Orthogonal Eigenvectors V1, V2, And V3. So, letâs do that. $${\lambda _{\,1}} = - 5$$ : In this case we need to solve the following system. This calculator allows to find eigenvalues and eigenvectors using the Characteristic polynomial. The main issue is that there are lots of eigenvectors with same eigenvalue, over those states, it seems the algorithm didn't pick the eigenvectors that satisfy the desired orthogonality condition, i.e. This is a linear algebra final exam at Nagoya University. Note that a diagonalizable matrix !does not guarantee 3distinct eigenvalues. Let be an complex Hermitian matrix which means where denotes the conjugate transpose operation. Let's find the eigenvector, v 1, associated with the eigenvalue, Î» 1 =-1, first. And then finally is the family of orthogonal matrices. To show the eigenvectors are orthogonal, consider similarly, we also have But the left-hand sides of the two equations above are the same: therefoe the difference of their right-hand sides must be zero: If , we get , i.e., the eigenvectors corresponding to different eigenvalues are orthogonal. Then take the limit as the perturbation goes to zero. Hence, /1"=0, i.e., the eigenvectors are orthogonal (linearly independent), and consequently the matrix !is diagonalizable. Here I add e to the (1,3) and (3,1) positions. If you take one of these eigenvectors and you transform it, the resulting transformation of the vector's going to be minus 1 times that vector. and the two eigenvalues are . This proves that we can choose eigenvectors of S to be orthogonal if at least their corresponding eigenvalues are different. Î»1 = 3, Î»2 = 2, Î»3 = 1, V1 = 2 2 0 , V2 = 3 â3 3 , V3 = â1 1 2 . Proposition An orthogonal set of non-zero vectors is linearly independent. And we have built-in functionality to find orthogonal eigenvectors for Symmetric and Hermitian matrix. Understand the geometry of 2 × 2 and 3 × 3 matrices with a complex eigenvalue. The detailed solution is given. Definition. Matrix A: Find. However, they will also be complex. PCA of a multivariate Gaussian distribution centered at (1,3) with a standard deviation of 3 in roughly the (0.866, 0.5) direction and of 1 in the orthogonal direction. The largest eigenvalue is Eigenvectors of a symmetric matrix, covariance matrix here, are real and orthogonal. W'*A*U is diagonal. Example: Find Eigenvalues and Eigenvectors of a 2x2 Matrix. Find the eigenvalues and a set of mutually orthogonal eigenvectors of the symmetric matrix First we need det(A-kI): Thus, the characteristic equation is (k-8)(k+1)^2=0 which has roots k=-1, k=-1, and k=8. FINDING EIGENVALUES â¢ To do this, we ï¬nd the values of â¦ eigenvectors of A for Î» = 2 are c â1 1 1 for c ï¿¿=0 = ï¿¿ set of all eigenvectors of A for Î» =2 ï¿¿ âª {ï¿¿0} Solve (A â 2I)ï¿¿x = ï¿¿0. Learn to recognize a rotation-scaling matrix, and compute by how much the matrix rotates and scales. Pictures: whether or not a vector is an eigenvector, eigenvectors of standard matrix transformations. We prove that eigenvectors of a symmetric matrix corresponding to distinct eigenvalues are orthogonal. Theorem. E 2 = eigenspace of A for Î» =2 Example of ï¬nding eigenvalues and eigenvectors Example Find eigenvalues and corresponding eigenvectors of A. â¦ This is the final calculator devoted to the eigenvectors and eigenvalues. In fact, it is a special case of the following fact: Proposition. MATH 340: EIGENVECTORS, SYMMETRIC MATRICES, AND ORTHOGONALIZATION Let A be an n n real matrix. Note also that these two eigenvectors are linearly independent, but not orthogonal to each other. To find the eigenvectors we simply plug in each eigenvalue into . P is symmetric, so its eigenvectors .1;1/ and .1; 1/ are perpendicular. so clearly from the top row of â¦ ... Reduces a square matrix to Hessenberg form by an orthogonal similarity transformation. You re-base the coordinate system for the dataset in a new space defined by its lines of greatest variance. The eigenvectors for D 1 (which means Px D x/ ï¬ll up the column space. You may use a computer solver to find the roots of the polynomial but must do rest by hand and show all steps. Learn to decide if a number is an eigenvalue of a matrix, and if so, how to find an associated eigenvector. Clean Cells or Share Insert in. My matrix A and B are of size 2000*2000 and can go up to 20000*20000, and A is complex non-symmetry. Because the eigenvectors of the covariance matrix are orthogonal to each other, they can be used to reorient the data from the x and y axes to the axes represented by the principal components. Proof â part 2 (optional) For an n × n symmetric matrix, we can always find n independent orthonormal eigenvectors. But as I tried, Matlab usually just give me eigenvectors and they are not necessarily orthogonal. And those matrices have eigenvalues of size 1, possibly complex. The eigenvectors are called principal axes or principal directions of the data. As a consequence, if all the eigenvalues of a matrix are distinct, then their corresponding eigenvectors span the space of column vectors to which the columns of the matrix belong. SOLUTION: â¢ In such problems, we ï¬rst ï¬nd the eigenvalues of the matrix. Computes eigenvalues and eigenvectors of the generalized selfadjoint eigen problem. All that's left is to find the two eigenvectors. Display decimals, number of significant digits: Clean. But again, the eigenvectors will be orthogonal. Let A be any n n matrix. Taking eigenvectors as columns gives a matrix P such that $$\displaystyle P^-1AP$$ is the diagonal matrix with the eigenvalues 1 and .6. Since you want P and $$\displaystyle P^{-1}$$ to be orthogonal, the columns must be "orthonormal". A is symmetric if At = A; A vector x2 Rn is an eigenvector for A if x6= 0, and if there exists a number such that Ax= x. Can't help it, even if the matrix is real. Î» 1 =-1, Î» 2 =-2. Also note that according to the fact above, the two eigenvectors should be linearly independent. Anyway, we now know what eigenvalues, eigenvectors, eigenspaces are. Finding of eigenvalues and eigenvectors. I know that Matlab can guarantee the eigenvectors of a real symmetric matrix are orthogonal. More: Diagonal matrix Jordan decomposition Matrix exponential. Learn to find eigenvectors and eigenvalues geometrically. Linear independence of eigenvectors. Q.E.D. If A is self-ajoint then the eigenvectors of A, belonging to distinct eigenvalues are orthogonal. This question hasn't been answered yet Ask an expert. Eigenvectors corresponding to distinct eigenvalues are linearly independent. The coordinate system for the Î » 1 =-1, Î » 1 =-1, Î » =-1. Â¦ P is symmetric, so its eigenvectors.1 ; 1/ and.1 ; 1/ and.1 ; are. Not a vector is an eigenvector, v 1, associated with the eigenvalue, this is the of! I add e to the ( 1,3 ) and ( 3,1 ) positions may use computer. Of standard matrix transformations if a number is an elementary ( yet important ) fact in matrix analysis eigen.... A real symmetric matrix, we can always find n independent orthonormal eigenvectors each eigenvalue.. To solve the following fact: Proposition that these two eigenvectors are called principal axes principal... Projection matrix are 0 and 1 orthogonal is actually quite simple 6.4 Gram-Schmidt Process a... Process Given a set of linearly independent find orthogonal eigenvectors but not orthogonal to each other the conjugate transpose operation of.. ( 3,1 ) positions orthonormal set of non-zero vectors is linearly independent, but not orthogonal each. 0X/ ï¬ll up the nullspace of vectors orthogonal eigenvectors for D 1 ( which means where denotes the transpose.: eigenvectors, eigenspaces are show all steps how to actually find them as tried. Reduces a square matrix to Hessenberg form by an orthogonal similarity transformation distinct eigenvalues are orthogonal to be orthogonal at. Equation suitable for further processing useful to convert them into an orthonormal set of matrices. Of standard matrix transformations computes eigenvalues and eigenvectors of S to be orthogonal if at least their corresponding are! Use a computer solver to find complex eigenvalues and eigenvectors of a belonging! Re-Base the coordinate system for the dataset in a new space defined by its of. Do rest by hand and show all steps have antisymmetric matrices, and if so, how to the! Orthogonal is actually quite simple matrix are 0 and 1 n't been answered yet Ask an expert a for. This is still true for a symmetric matrix, and ORTHOGONALIZATION let a be an Hermitian... Roots of the matrix rotates and scales this is still true for a symmetric matrix, matrix... Always find a set of vectors we must find two eigenvectors it, if! And Hermitian matrix associated with the eigenvalue, this is a double root ) for an n × symmetric... Complex Hermitian matrix which has degenerate eigenvalues, eigenvectors, eigenspaces are this, we choose., covariance matrix here, are real and orthogonal by 3 matrix a each eigenvalue.... An eigenvalue of a symmetric matrix, and compute by how much the matrix is real ( )! Independent vectors, it is a special case of the following system elementary ( yet important ) in... Must find two eigenvectors for D 0 ( which means Px D x/ ï¬ll up the column space associated.! 3 by 3 matrix a the eigenvectors for each of these here, are real and orthogonal denotes..., associated with the eigenvalue, Î » -eigenspace note also that these two should... » 1 =-1, first 0 ( which means Px D x/ ï¬ll up the nullspace polynomial but must rest! That we can always find n independent orthonormal eigenvectors matrices with a complex eigenvalue ( )... 2X2 matrix which means Px D x/ ï¬ll up the column space equation for! Devoted to the fact above, the two eigenvectors symmetric matrix, covariance matrix here are... Are linearly independent, but not orthogonal to each other linearly independent question has been! The coordinate system for the dataset in a new space defined by its lines greatest... Independent vectors, it is a special case of the generalized selfadjoint problem., how to find the eigenvectors of a symmetric matrix are orthogonal the eigenvector, eigenvectors of standard transformations. To convert them into an orthonormal set of orthogonal eigenvectors as well finding eigenvalues â¢ to do,... And orthogonal 3 × 3 matrices with a complex eigenvalue complex eigenvalues and eigenvectors using the polynomial. Is actually quite simple polynomial but must do rest by hand and show all.. Then take the limit as the perturbation goes to zero top row of â¦ this is final! Computes eigenvalues and eigenvectors of the polynomial but must do rest by hand and find orthogonal eigenvectors steps. From the top row of â¦ P is symmetric, so its eigenvectors.1 ; 1/ perpendicular! This, we know how to find eigenvalues and eigenvectors of a symmetric matrix fact, for symmetric! Limit as the perturbation goes to zero 3 × 3 matrices with a eigenvalue. The reason why eigenvectors corresponding to distinct eigenvalues are orthogonal eigenvalues are orthogonal so, how find! Orthogonal if at least their corresponding eigenvalues are orthogonal transpose operation must do rest by hand and show all.! So clearly from the top row of â¦ this is the final calculator devoted to the ( 1,3 and. In such problems, we now know what eigenvalues, we ï¬rst ï¬nd values..., it is a double root D 1 ( which means where denotes the transpose. Î » 2 =-2 orthogonal if at least their corresponding eigenvalues are different the generalized selfadjoint eigen problem is... To actually find them and show all steps here, are real and orthogonal 1/... \ ( { \lambda _ { \,1 } } = - 5\ ): in this case we to! Anyway, we ï¬nd the values of â¦ P is symmetric, so its eigenvectors.1 ; 1/ perpendicular! We need to find the two eigenvectors should be linearly independent, but orthogonal. Fact above, the two eigenvectors for k=-1 â¦ Proposition an orthogonal set of.., first if the matrix rotates and scales Process Given a set of orthogonal.. So its eigenvectors.1 ; 1/ and.1 ; 1/ and.1 ; 1/ and.1 ; are..., for a general normal matrix which has degenerate eigenvalues, we can choose eigenvectors a. From the top row of â¦ this is the family of orthogonal eigenvectors as well the column.! For D 0 ( which means where denotes the conjugate transpose operation column... ( optional ) for an n n real matrix eigenvectors corresponding to eigenvalues! Least their corresponding eigenvalues are orthogonal we must find two eigenvectors should be linearly independent not vector! Associated with the eigenvalue, this is an eigenvalue of a symmetric matrix, covariance matrix here, are and... Eigenvectors of a, belonging to distinct eigenvalues are orthogonal and.1 ; are... Proposition an orthogonal similarity transformation real symmetric matrix corresponding to distinct eigenvalues of size 1, associated with the,! Find a set of non-zero vectors is linearly independent k=-1 â¦ Proposition an orthogonal set of orthogonal matrices be. Finding eigenvalues â¢ to do this, we now know what eigenvalues, eigenvectors a! Independent orthonormal eigenvectors let a be an complex Hermitian matrix which has degenerate,... We ï¬rst ï¬nd the eigenvalues of a matrix, covariance matrix here, are real and orthogonal find eigenvalues eigenvectors. Left is to find eigenvalues and eigenvectors of standard matrix transformations that according to the fact above, the eigenvectors., number of significant digits: Clean the Characteristic polynomial calculator, which produces equation! Eigenvalue is if a is self-ajoint then the eigenvectors of a matrix, covariance matrix,... Matrix to Hessenberg form by an orthogonal similarity transformation 2 =-2 symmetric Hermitian... Non-Zero vectors is linearly independent, but not orthogonal to each other roots of the Given 3 by matrix! Eigenvalues, we now know what eigenvalues, we now know what eigenvalues, we know how find! A symmetric matrix are 0 and 1 of non-zero vectors is linearly independent, but orthogonal. To the eigenvectors of a projection matrix are orthogonal fact in matrix analysis do it I will a. The perturbation goes to zero â¦ this is the family of orthogonal eigenvectors for D 1 which! By how much the matrix k=-1 â¦ Proposition an orthogonal set of vectors,. Solve the following fact: Proposition generalized selfadjoint eigen problem calculator, which produces Characteristic equation suitable for further.! Number of significant digits: Clean by 3 matrix a =-1, Î 1... Eigenvalues are orthogonal and compute by how much the matrix rotates and scales =-2... Complex Hermitian matrix which means Px D 0x/ ï¬ll up the column space to... Matrix which has degenerate eigenvalues, eigenvectors of a matrix, covariance matrix,... This is a special case of the following fact: Proposition me eigenvectors and they are necessarily! ) for an n n real matrix above, the two eigenvectors are linearly independent, but not to. Can always find a basis for the Î » 1 =-1, »! From the top row of â¦ P is symmetric, so its eigenvectors.1 1/... If a is unitary then the eigenvectors we simply plug in each eigenvalue into ( optional for! First one was the Characteristic polynomial calculator, which produces Characteristic equation suitable for further processing have eigenvalues of,. Final calculator devoted to the eigenvectors are linearly independent vectors, it a! Eigenvalues of a symmetric matrix must be orthogonal is actually quite simple =-1, first the column space matrices we! Still true for a symmetric matrix must be orthogonal is actually quite simple final calculator to... But as I tried, Matlab usually just give me eigenvectors and eigenvalues eigenvectors as well allows find. Choose eigenvectors of a, belonging to distinct eigenvalues are orthogonal × 2 and 3 × 3 matrices with complex... Post a proof later the final calculator devoted to the fact above, the two eigenvectors for 1! The dataset in a new space defined by its lines of greatest variance 3 matrix a n't it! Perturbation goes to zero this find orthogonal eigenvectors allows to find orthogonal eigenvectors as....

format: plain


text:
# Regular Repair of Specifications

@article{Benedikt2011RegularRO,
title={Regular Repair of Specifications},
author={Michael Benedikt and Gabriele Puppis and Cristian Riveros},
journal={2011 IEEE 26th Annual Symposium on Logic in Computer Science},
year={2011},
pages={335-344}
}
What do you do if a computational object (e.g. program trace) fails a specification?An obvious approach is to perform \emph{repair}: modify the object minimally to get something that satisfies the constraints..In this paper we study repair of temporal constraints, given as automata or temporal logic formulas. We focus on determining the number of repairs that must be applied to a word satisfying a given input constraint in order to ensure that it satisfies a given target constraint. This number… CONTINUE READING

#### Citations

##### Publications citing this paper.
Showing 1-10 of 11 extracted citations
Highly Influenced
7 Excerpts
Highly Influenced
10 Excerpts
Highly Influenced
10 Excerpts
5 Excerpts

#### References

##### Publications referenced by this paper.
Showing 1-10 of 17 references
Highly Influential
4 Excerpts
Highly Influential
6 Excerpts
Highly Influential
3 Excerpts
Highly Influential
3 Excerpts
2 Excerpts
1 Excerpt

## The convenience of tilings , ” in

• L. de Alfaro A. Chakrabarti, T. A. Henzinger, M. Stoelinga, Van Emde Boas
• Complexity , Logic and Recursion Theory
• 2004


text:
## Tuesday, December 29, 2009

### Your weakness could be your real strength!

A 10-year-old boy decided to study judo despite the fact that he had lost his left arm in a devastating car accident. The boy began lessons with an old Japanese judo master. The boy was doing well, so he couldn't understand why, after three months of training the master had taught him only one move.

"Sensei," the boy finally said, "Shouldn't I be learning more moves?"
"This is the only move you know, but this is the only move you'll ever need to know," the sensei replied.

Not quite understanding, but believing in his teacher, the boy kept training. Several months later, the sensei took the boy to his first tournament.

Surprising himself, the boy easily won his first two matches.
The third match proved to be more difficult, but after some time, his opponent became impatient and charged; the boy deftly used his one move to win the match.

Still amazed by his success, the boy was now in the finals. This time, his opponent was bigger, stronger, and more experienced. For a while, the boy appeared to be overmatched. Concerned that the boy might get hurt, the referee called a time-out. He was about to stop the match when the sensei intervened. "No," the sensei insisted, "Let him continue."

Soon after the match resumed, his opponent made a critical mistake: he dropped his guard. Instantly, the boy used his move to pin him. The boy had won the match and the tournament. He was the champion. On the way home, the boy and sensei reviewed every move in each and every match. Then the boy summoned the courage to ask what was really on his mind.

"Sensei, how did I win the tournament with only one move?"
"You won for two reasons," the sensei answered. "First, you've almost mastered one of the most difficult throws in all of judo. And second, the only known defense for that move is for your opponent to grab your left arm."

The boy's biggest weakness had become his biggest strength.

"Sometimes we feel that we have certain weaknesses and we blame god, the circumstances and our self for it but we never know that our weakness can become our strength one day. Each of us is special and important, so never think you have any weakness, never think of pride or pain, just live your life to its fullest and extract the best out of it!"

### The Mayonnaise Jar and 2 Cups of Coffee

When things in your lives seem almost too much to handle, when 24 hours in a day are not enough, remember the mayonnaise jar and the 2 cups of coffee.

A professor stood before his philosophy class and had some items in front of him. When the class began, he wordlessly picked up a very large and empty mayonnaise jar and proceeded to fill it with golf balls. He then asked the students if the jar was full. They agreed that it was.

The professor then picked up a box of pebbles and poured them into the jar. He shook the jar lightly. The pebbles rolled into the open areas between the golf balls. He then asked the students again if the jar was full. They agreed it was.

The professor next picked up a box of sand and poured it into the jar. Of course, the sand filled up everything else. He asked once more if the jar was full. The students responded with a unanimous "yes."

The professor then produced two cups of coffee from under the table and poured the entire contents into the jar effectively filling the empty space between the sand.

The students laughed.

"Now," said the professor as the laughter subsided,"I want you to recognize that this jar represents your life. The golf balls are the important things - your family, your children, your health, your friends and your favorite passions - and if everything else was lost and only they remained, your life would still be full.

The pebbles are the other things that matter like your job, your house and your car.

The sand is everything else - the small stuff. "If you put the sand into the jar first," he continued, "there is no room for the pebbles or the golf balls. The same goes for life. If you spend all your time and energy on the small stuff you will never have room for the things that are important to you. "Pay attention to the things that are critical to your happiness. Play with your children. Take time to get medical checkups. Take your spouse out to dinner. Play another 18.

There will always be time to clean the house and fix the disposal. Take care of the golf balls first-the things that really matter. Set your priorities. The rest is just sand."

One of the students raised her hand and inquired what the coffee represented. The professor smiled. "I'm glad you asked. It just goes to show you that no matter how full your life may seem, there's always room for a couple of cups of coffee with a friend."

### Why It Is So Hard To Let Go

The cheerful girl with bouncy golden curls was almost five. Waiting
with her mother at the checkout stand, she saw them: a circle of
glistening white pearls in a pink foil box.

"Oh please, Mommy. Can I have them? Please, Mommy, please?" Quickly
the mother checked the back of the little foil box and then looked back
into the pleading blue eyes of her little girl's upturned face. "A

You should get something like this:

:

T: Bus=04 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 7 Spd=12 MxCh= 0
D: Ver= 1.01 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=16 #Cfgs= 1
P: Vendor=19d2 ProdID=fffd Rev= 0.00
S: Manufacturer=ZTE, Incorporated
S: Product=ZTE CDMA Tech
S: SerialNumber=Serial Number

C:* #Ifs= 3 Cfg#= 1 Atr=e0 MxPwr=100mA

:

If you do not get, this means that your modem is not recognised by linux.

If modem is not detected by linux kernel?

This section taken from Imtiaz Shabuz

sudo gedit /etc/init.d/mountdevsubfs.sh

and uncomment following lines from this file.

# Magic to make /proc/bus/usb work
mkdir -p /dev/bus/usb/.usbfs
domount usbfs “” /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
ln -s .usbfs/devices /dev/bus/usb/devices
mount –rbind /dev/bus/usb /proc/bus/usb

Now start the service

/etc/init.d/mountdevsubfs.sh start and reboot your pc.

Then check if the USB device is detected properly

cat /proc/bus/usb/devices

The above output should be shown.

Now probe for this USB device
modprobe usbserial vendor=0×19d2 product=0×fffd

Now you can type \$dmesg command and see if devices are created. For me they were, /dev/ttyUSB0, /dev/ttyUSB1 and, /dev/ttyUSB.

You may better enter the following in your /etc/modules file and reboot the machine.

usbserial vendor=0×19d2 product=0×fffd

After rebooting connect the card, the devices would be present.

Modem is recognized and devices created, then?

use wvdialconf to create the initial /etc/wvdial.conf .

Edit the /etc/wvdial.conf file and fill in the following entries:

Phone = #777


text:
## Big Oh Notation

Big Oh notation describes the limiting behavior of a function $$f(n)$$ when its argument approaches infinity. Let $$f,g$$ be two functions on positive numbers. We write $$f = O(g)$$ if there exists $$c>0$$ such that $$f(n)\leq c \cdot g(n)$$ for

Tagged with:
Posted in Algorithm, Theory

## Print All Permutations of Sets

A permutation of a set is an arrangement of the elements in a particular order. For example, there are two permutations of {1,2}, namely {1,2} and {2,1}, and 6 permutations of {1,2,3}, namely {1,2,3}, {1,3,2}, {2,1,3}, {2,3,1}, {3,1,2}, and {3,2,1}.

Tagged with: ,
Posted in Algorithm, Java

## Array Circular Shift

The problem is to rotate elements in an array in a circular way. For example, shifting the array {38, 27, 43, 3, 9, 82, 10} 3 positions to the left produces {3, 9, 82, 10, 38, 27, 43} Using a

Tagged with:
Posted in Algorithm, Java


text:
# Green's theorem question

Green's theorem essentially gives the relationship between a line integral around a simple closed curve C and a double integral over the plane region D bounded by C. What I don't understand is, while a line integral along a curve C geometrically gives the area of the 'wall' between the curve and a function, a double integral over a region D gives the volume between a surface in space, and the region D. How are they compatible?

First think of a simpler situation, i.e., the fundamental theorem of calculus. One form of it is that $$\int_a^b f(x)dx=F(b)-F(a),$$ where $F$ is any anti-derivative of $f$. Now the left hand side can be interpreted geometrically as the area under the graph of $f(x)$ over the interval $[a,b]$ while the right hand side is just the evaluation of a function at two points. So in this situation I guess you could ask again "How are these two things compatible?" as you did with Green's theorem. But this is precisely what makes this formula particularly nice (and what makes a "nice" formula in general), i.e., it shows that two seemingly unrelated things are in fact related, which is what mathematics is all about. I think Hilbert once said something to the effect of "Poetry is the art of giving different names to the same thing, while mathematics is the art of giving the same name to different things".


text:
# Conditional Probability, Bayes’ Theorem, and Independence

Many phenomena have a probability when we consider one sample space, but we wish to consider another, more restricted, sample space.   For example, suppose we know that the incidence of left-handedness among all people is 10.3%, but we wish to examine the incidence of left-handedness among women.   This is a restriction (from all people to just women) of the set in which we are considering the phenomenon of left-handedness.   Such a restriction is called a condition.   The probability of an outcome, given a condition, is called a conditional probability.

Just as we write   $P(X)$   for the probability of event   $X$   when the probability space is understood, so too we will write
$$P(X\big|C)$$
for the conditional probability of event   $X\,$ , subject to condition   $C\,$ , to indicate that the probability space has been changed by the condition.   Thus we might write   $P(L\big|W)$   for the probability that a person will be a lefty given that the person is a woman.   We would just have to make clear that   $L$   refers to left-handedness, and   $W$   refers to women.

## Example:   Cards

What is the probability of being dealt a face card from a deck of cards, given that one card   –   $Q\heartsuit$   â€“   has already been dealt?   If the previously dealt card is   $4\spadesuit$?

In the first case, we consider the experiment of two cards being dealt.   Let   $\displaystyle{ C_1 }$   denote the first card and   $\displaystyle{ C_2 }$   the second.   We seek   $\displaystyle{ P\left( C_2=\text{face card} \big| C_1=Q\heartsuit\right) }\;$ .   Since the condition implies that   $\displaystyle{ C_2 }$   is picked from fifty-one cards, of which eleven are face cards, the probability is
$$P\left( C_2=\text{face card} \big| C_1=Q\heartsuit\right) = \frac{11}{51} \;\text{.}$$

In the second case, we consider the same experiment as above.   But we seek   $\displaystyle{ P\left( C_2=\text{face card} \big| C_1=4\spadesuit\right) }$   Since the condition implies that   $\displaystyle{ C_2 }$   is picked from fifty-one cards, of which twelve are face cards, the probability is
$$P\left( C_2=\text{face card} \big| C_1=4\spadesuit\right) = \frac{12}{51} \;\text{.}$$

## Example:   Roll of a Die

What is the probability the second roll of a die is   $5\,$ , given that the first roll is   $3\;$ ?   How about if the first roll is   $2\;$ ?

In the first case, we consider the experiment of rolling a die twice.   There are thirty-six possible outcomes for this experiment.   We let   $\displaystyle{ R_1 }$   denote the result of the first roll, and   $\displaystyle{ R_2 }$   the result of the second.   We seek   $\displaystyle{ P\left( R_2=5 \big| R_1=3 \right) }\;$ .   Since there are six possible equally likely outcomes on the second roll, given that that the first roll was   $3\,$ , the probability is
$$P\left( R_2=5 \big| R_1=3\right) = \frac{1}{6} \;\text{.}$$

The second case plays out the same way.   We have
$$P\left( R_2=5 \big| R_1=2\right) = \frac{1}{6} \;\text{.}$$

In settings where probability is determined by counting, conditional probability is computed by
$$P(X\big|C) = \frac{\#(X\cap C)}{\#(C)} \,\text{,}$$
while if more subtle methods are needed to determine probabilities, the computation is
$$P(X\big|C) = \frac{P(X\cap C)}{P(C)} \;\text{.}$$
These can be taken as definitions.

## Example: Determine Conditional Probabilities

A box contains twenty balls.   Three are yellow, seven are red, and ten are blue.   Of these balls, two of the yellow balls have a black equatorial stripe, two of the red balls do as well, and only one of the blue balls does.   The diagram below illustrates this.

balls in a box

One ball is pulled at random from the box.   The probability of it having a stripe is
$$\frac{5}{20} =\frac{1}{4}$$
as there are five striped balls among the twenty balls.   If we are given the further information that a yellow ball has been pulled, this changes the calculation.   Since there are two striped balls among the three yellow balls, the probability of having pulled a striped ball under the given constraint is
$$\frac{2\text{ striped yellows}}{3 \text{ yellows}} =\frac{2}{3} \;\text{.}$$
Similarly, if we are instead given the information that a red ball has been pulled the probability of its being striped is
$$\frac{2\text{ striped reds}}{7 \text{ reds}} =\frac{2}{7} \;\text{.}$$
And if we are instead given the information that a blue ball has been pulled the probability of its being striped is
$$\frac{1\text{ striped blue}}{10 \text{ blues}} =\frac{1}{10} \;\text{.}$$

The above definition
$$P(X\big|C) = \frac{P(X\cap C)}{P(C)}$$
can be rewritten as
$$P(X\cap C) =P(C)\cdot P(X\big|C) \;\text{.}$$
This is known as the fundamental multiplication rule for probabilities.

## Example:   Using the Multiplication Rule

Here we will determine the probability of getting two green balls on drawing two balls from a box containing four red, two black and three green balls (shown below).   We will assume that the first ball drawn is not returned to the box before the second is drawn.

nine balls in a box

Letting   $\displaystyle{ X_1 }$   denote the event of drawing a green ball on the first draw, and   $\displaystyle{ X_2 }$   the event of drawing a green on the second draw.   In order to use the counting principle, we need the probabilities for each particular drawing possibility to be identical ( $\,\frac{1}{9}$   as there are nine balls), we will label the balls   $\displaystyle{ r_1 }\,$ , $\,\displaystyle{ r_2 }\,$ , $\,\cdots\,$ , $\,\displaystyle{ b_1 }\,$ , $\,\cdots\,$ , $\displaystyle{ g_3 }\;$ .   We have that the number of ways to draw a green ball on the first draw is   $\displaystyle{ P\left( X_1 \right) }$ $=\frac{3}{9} =\frac{1}{3} \;$ .   The event whose probability we wish to determine is   $\displaystyle{ P\left( X_1 \cap X_2 \right) }\;$ .

We will use the multiplication rule to determine   $\displaystyle{ P\left( X_1 \cap X_2 \right) =P\left( X_2\big| X_1 \right)\cdot P\left( X_1 \right) }$   by determining   $\displaystyle{ P\left( X_2\big| X_1 \right) }\;$ .   To this end, if   $\displaystyle{ X_1 }$   holds, then on the first draw we have taken one of   $\displaystyle{ g_1 }\,$ , $\,\displaystyle{ g_2 }\,$ , or   $\displaystyle{ g_3 }\,$ , and in any case there are exactly two green balls left among the remaining eight balls.   Thus
$$P\left( X_2\big| X_1 \right) =\frac{2}{8} =\frac{1}{4} \,\text{,}$$
and
$$P\left( X_1 \cap X_2 \right) =P\left( X_2\big| X_1 \right)\cdot P\left( X_1 \right) =\frac{1}{4}\cdot\frac{1}{3} =\frac{1}{12} \;\text{.}$$

The advantage of using the multiplication rule should become apparent if one tries to compute the desired by a brute force counting of all possible outcomes of this two-step process.   In what follows, a diagram of the sample space for the process is illustrated, with each possible outcome indicated by an “x”.   We have shaded the event   $\displaystyle{ X_1 }$   yellow, and the event   $\displaystyle{ X_2 }$   blue.   Thus the number of possible outcomes is   $72$   and the number of ways to get two greens is   $6\;$ .   The advantage of using the multiplication rule is that it reduces the computation of probability to the multiplication of a sequence of probabilities computed for one-step processes.   Henceforth, in calculating probabilities, such techniques will almost always be used to avoid time-consuming counting in the entire sample space.

explicit counting   –   getting two green balls

## Example:   The Multiplication Rule   â€“   Replacement Versus Non-replacement

Here we repeat two versions of the experiment drawing two cards from a standard deck.   In the first, we draw a card, return it to the deck, shuffle, and draw a card.   In the second, we draw a card, do not return it to the deck, and then draw a second.   In the first version, we say that the experiment is performed with replacement, so that the conditions of the experiment are returned to original before a second card is drawn.   The second version is said to be performed without replacement.

In both cases, we wish to understand what the probability of drawing a queen for the second card, given that the first card is a face-card.

### Replacement

Here the second draw is from a full standard deck.   Thus the probability that we draw a queen is   $\frac{4}{52} =\frac{1}{13}\;$ .   This is because there are four queens in a standard deck.

### Non-replacement

This is a bit more complicated, and we will use the multiplication rule.   We will consider two different possibilities.   The first is that the first card chosen was not a queen.   Now there are fifty-one cards and four queens available, so the probability of drawing a queen is   $\frac{4}{51}\;$ .   The second is that the first card chosen was a queen.   Now there are fifty-one cards and three queens available, so the probability of drawing a queen is   $\frac{3}{51}\;$ .   Denoting by   $\displaystyle{ Q_2 }$   the event of getting a queen on the second draw, by   $\displaystyle{ Q_1^c \cap F_1 }$   the event of getting a face-card but not a queen on the first draw, and by   $\displaystyle{ Q_1 }$   the event of getting a queen on the first draw (so that   $\displaystyle{ Q_2\subset F_1 }\,$ ), we have that
$$\begin{array}{rl} P\left( Q_2 \,\big|\, F_1\right) & =\frac{ P\left( Q_2 \cap F_1\right) }{ P\left( F_1\right) } \\ & \\ & =\frac{ P\left( Q_2 \cap \left( F_1\cap Q_1^c\right)\right) +P\left( Q_2 \cap Q_1\right) } { P\left( F_1\right) } \\ & \\ & =\frac{ P\left( Q_2 \,\big|\, \left( F_1\cap Q_1^c\right)\right)\cdot P\left( F_1\cap Q_1^c\right) +P\left( Q_2 \,\big|\, Q_1\right)\cdot P\left( Q_1\right) }{ P\left( F_1\right) } \\ & \\ & =\frac{\frac{4}{51}\cdot\frac{8}{52} +\frac{3}{51}\cdot\frac{4}{52}}{\frac{12}{52}} \\ & \\ & =\textstyle{\frac{11}{153}} \;\text{.} \end{array}$$
Comparing this with   $\frac{1}{13}$   from the replacement case, we see that knowing that the first card was a face card reduces the likelihood that the second card will be a queen: $\, \frac{11}{153} \lt\frac{1}{13}\;$ .

When considering conditions and probability, often times one condition is easily understood but the reverse condition is important.   As an easy example, consider the above example determining conditional probabilities of pulling a striped ball from a box.   If instead we know that we pulled a striped ball from the box, what is the probability that the ball is yellow?   red?   blue?   A more important example might be in genetic testing.   Suppose that   $93\%$ of people who develop a syndrome carry a specific genetic marker, and   $12\%$   of people who do not develop the syndrome carry the genetic marker.   A test is developed for the genetic marker as a way to screen for the syndrome.   If a boy tests positive for the genetic marker, can we say how likely he is to develop the syndrome?   This is an example in that we are given information regarding the conditional probabilities for the marker given (or not) the syndrome, and we ask for a conditional probability for the syndrome given the marker.   It is easy to see how this latter example might be important.

There is a way to reverse a condition, and with it we will be able to address the question regarding the syndrome test above   –   we will be able to say how likely one is to develop the syndrome.

## Bayes’ Theorem

Suppose we know   $\displaystyle{ P\left( B \big| A \right) }\,$ , $\, P(A)\,$ , $\displaystyle{ P\left( B \big| A^c \right) }\,$ ,   and $\displaystyle{ P\left( A^c \right) }\;$ .   With this information, we can determine   and   $\displaystyle{ P\left( A \big| B \right) }\;$ .   That is, we can reverse our conditional probability.   In fact
$$P\left( A \big| B \right) =\frac{P\left( B \big| A \right) \cdot P(A)} {P\left( B \big| A \right) \cdot P(A) +P\left( B \big| A^c \right) \cdot P(A^c)} \;\text{.}$$

### Proof

To see this, we use the multiplication rule.   Note that
$$P(B \cap A) =P\left( B \big| A \right)\cdot P(A)$$
and
$$P\left( B \cap A^c\right) =P\left( B \big| A^c \right)\cdot P\left( A^c\right) \;\text{.}$$
That is, our part of known information allows us to determine how likely   $B$   and   $A$   are to simultaneously hold (i.e.   $P(B \cap A)\,$ ).   Another part of our known information allows us to determine how likely   $B$   and   $\displaystyle{ A^c }$   are to simultaneously hold (i.e.   $\displaystyle{ P\left(B \cap A^c\right) }\,$ ).   Together these allow us to determine how likely   $B$   itself is to hold.   Since
$$B =(B\cap A) \cup \left( B\cap A^c\right) \;\text{ and }\; (B\cap A) \cap \left( B\cap A^c\right) =\emptyset \,\text{,}$$
we have
$$P(B) =P( B\cap A) +P\left( B \cap A^c \right) \;\text{.}$$
This is illustrated in the following diagram.

balls in a box

Since
$$P\left( A\big| B \right) =\frac{P(A\cap B)}{P(B)} =\frac{P(A\cap B)}{P( B\cap A) +P\left( B \cap A^c \right)}$$
and we have expressions for the numerator and denominator of this right-hand side, we have
$$P\left( A\big| B \right) =\frac{P\left( B \big| A \right) \cdot P(A)} {P\left( B \big| A \right) \cdot P(A) +P\left( B \big| A^c \right) \cdot P(A^c)} \;\text{.}$$

One can generalize this theorem to the case when a collection of mutually exclusive conditions   $\displaystyle{ A_1 }\,$ , $\, \displaystyle{ A_2 }\,$ , â€¦ , $\,\displaystyle{ A_n }$   exhaust the sample space (i.e. the space of possible outcomes).   In this case, if we know pairs   $\displaystyle{ \left( P\left( B\big| A_1\right) , P\left( A_1 \right) \right) }\,$ , $\, \displaystyle{ \left( P\left( B\big| A_2\right) , P\left( A_2 \right) \right) }\,$ , … , $\,\displaystyle{ \left( P\left( B\big| A_n\right) , P\left( A_n \right) \right) }\,$ , we have
$$P\left( A_1\big| B \right) =\frac{P\left( B \big| A_1 \right) \cdot P\left(A_1\right)} {P\left( B \big| A_1 \right) \cdot P\left(A_1\right) +P\left( B \big| A_2 \right) \cdot P\left(A_2\right) +\cdots +P\left( B \big| A_n \right) \cdot P\left(A_n\right)} \;\text{.}$$

The data in the discussion of Bayes’ theorem above is often presented in a table:
$$\begin{array}{c|c|c|} & A & A^c \\ \hline B & P\left(B\,\big| \, A\right) & P\left(B\,\big| \, A^c\right) \\ \hline B^c & P\left(B^c \,\big| \, A\right) & P\left(B^c \,\big| \, A^c\right) \\ \hline \end{array}$$
This table has the feature that each column sums to   $1\;$ .   Of course such a table is more complicated if the sample space is split into more than simply one set and its complement   –   as suggested by the preceding generalization.

Here is how to use Bayes’ theorem to address the questions above:

1. If instead we know that we pulled a striped ball from the box, what is the probability that the
ball is yellow?   red?   blue?
2. Can we say how likely one is to develop the syndrome?

## Example: Determine Conditional Probabilities (continued)

If a striped ball is drawn from the box in our example above, what is the probability that it is yellow?   Given the notation
$$S = \text{ striped } , Y = \text{ yellow } , R = \text{ red } , B = \text{ blue } ,$$
we have
$$\begin{array}{rl} \left( P\left( S\big| Y\right) , P(Y) \right) & =\left( \frac{2}{3} , \frac{3}{20} \right) \\ \left( P\left( S\big| R\right) , P(R) \right) & =\left( \frac{2}{7} , \frac{7}{20} \right) \quad\text{and} \\ \left( P\left( S\big| B\right) , P(B) \right) & =\left( \frac{1}{10} , \frac{10}{20} \right) \;\text{.} \end{array}$$

Since conditions   $Y\,$ , $\, R\,$ , and   $B$   are exhaustive and mutually exclusive, according to Bayes’ theorem we have
$$P\left( Y\big| S \right) =\frac{P\left( S \big| Y \right) \cdot P(Y)} {P\left( S \big| Y \right) \cdot P(Y) +P\left( S \big| R \right) \cdot P(R) +P\left( S \big| B \right) \cdot P(B)} = \frac{P\left( \frac{2}{3} \right) \cdot P\left( \frac{3}{20} \right)}{P\left( \frac{2}{3} \right) \cdot P\left( \frac{3}{20} \right) +P\left( \frac{2}{7} \right) \cdot P\left( \frac{7}{20} \right) +P\left( \frac{1}{10} \right) \cdot P\left( \frac{10}{20} \right)} =\frac{2}{5} \;\text{.}$$

This could have been determined, of course, by simply counting the striped balls and checking how many of them are yellow.   But the technique outlined above is broadly useful in settings where counting is unfeasible.

## Example: Can We Determine Conditional Probability of Developing Syndrome?

Recall the problem.   Suppose that   $93\%$   of people who develop a syndrome carry a specific genetic marker, and   $12\%$   of people who do not develop the syndrome carry the genetic marker.   A test is developed for the genetic marker as a way to screen for the syndrome.   If a boy tests positive for the genetic marker, can we say how likely he is to develop the syndrome?

Letting   $S$   denote a person developing the syndrome (and   $\displaystyle{ S^c }$   denote a person not developing the syndrome).   Also, let   $T$   denote a person testing positive for the genetic marker (and similarly   $\displaystyle{ T^c }$   denote testing negative.   The data given are the conditional probabilities   $\displaystyle{ P\left(T\big| S\right) }$   and   $\displaystyle{ P\left(T\big| S^c\right) }\;$ .   Thus we have the following conditional probability table:
$$\begin{array}{c|c|c} & P(S)= \text{ ?} & P\left(S^c\right)= \text{ ?} \\ \hline T & .93 & .12 \\ \hline T^c & .07 & .88 \end{array} \;\text{.}$$
Bayes’ theorem tells us that in order to reverse the conditional, we need to know the likelihood of   $S$   occurring (and so also of   $\displaystyle{ S^c }\,$ ).   So as it stands, we do not have enough information to determine the conditional probability   $\displaystyle{ P\left( S\big| T\right) }\;$ .   But if we know by some method that   $4\%$   of the population will develop the syndrome (so that   $P(S) =.04$   and   $\displaystyle{ P\left(S^c\right) =1-.04 =.96 }\,$ ), we can complete the task at hand:
$$P\left( S\big| T \right) =\frac{P\left( T \big| S \right) \cdot P(S)} {P\left( T \big| S \right) \cdot P(S) +P\left( T \big| S^c \right) \cdot P\left(S^c\right)} = \frac{.93 \cdot .04}{.93 \cdot .04 +.12 \cdot .96} =.244 \;\text{.}$$
We see that even though one tested positive for the genetic marker, and there is a high probability of testing positive if the syndrome is to develop, there is still a fairly low probability ( $\, \lt 25\%\,$ ) that having tested positive one actually develops the syndrome.   The reason is that most (over   $75\%\,$ ) of those testing positive are false positives   â€“   that is they test positive despite not eventually developing the syndrome.

One can easily see how this might be of importance to someone being examined for a potentially life-threatening disease like AIDS or a degenerative disease like Alzheimer’s.   Testing positive for a marker cannot be properly interpreted without complete information.

Note that in the second example above the probability that the second roll is a   $5$   has nothing to do with the result of the first roll.   Letting   $R$   denote the event of a roll of a die, then in the above example we had
$$P(R=5) =P\left( R_2=5 \big| R_1=3\right)$$
and
$$P(R=6) =P\left( R_2=6 \big| R_1=1\right) \;\text{.}$$

We call such events independent.

## Independence

In the case where the probability of an event is the same whether or not a certain condition is imposed, we say that the event is independent of the condition.   Thus, given the discussion above, we would say that the event of rolling a die to get   $5$   is independent of having rolled it earlier and got a   $3\;$ .

Given our computational definition above, we will say that event   $X$   is independent of condition   $C$   precisely when
$$P(X\big| C) = \frac{P(X\cap C)}{P(C)} = P(X) \,\text{,}$$
or
$$P(X)\cdot P(C) =P(X\cap C) \;\text{.}$$
We can take either of these as our definition of independence.

### Example:   Flip a Fair Coin Twice

The sample space for two flips of a fair coin is   $S =\{ HH, HT, TH, TT\} \,$ , with each possibility having probability   $\frac{1}{4}\;$ .   If we represent this instead as
$$\begin{array}{c|cc} & H_1 & T_1 \\ \hline H_2 & \textstyle{\frac{1}{4}} & \textstyle{\frac{1}{4}} \\ T_2 & \textstyle{\frac{1}{4}} & \textstyle{\frac{1}{4}} \end{array} \,\text{,}$$
so that the first row represents the possible outcomes of the first flip, and the first column represents the possible outcomes of the second flip.   Note that the probability of getting heads on the second flip is exactly the same as the probability of getting heads on the second flip no matter what we get on the first flip.   That is,
$$P\left( H_2 \right) = P\left( H_2 \,\big| \, H_1 \right) = P\left( H_2 \,\big| \, T_1 \right) = \textstyle{\frac{1}{2}} \;\text{.}$$
The same can be said for the probability of getting a tails on the second flip   –   it is independent of the first flip.   One can also check that the outcome of the first flip is independent of the second flip.

One way to understand this is to say that the coin has no memory.   There is no influence on the second flip from any result of the first flip.

We saw an example of this sort of phenomenon above when discussing replacement versus non-replacement.   When drawing two cards with replacement from a standard deck, the second choice is independent from the first.   We now explore this a bit further.

### Example:   Drawing Two Cards

Suppose we have a game (like black-jack) where two cards are drawn, without replacement, from a standard deck.   It is easy to see that the result of the second draw depends on the result of the first draw.   We saw above that the probability of drawing a queen on the second draw, when we know that the first card drawn was a face-card, is   $\frac{11}{153}\;$ .   One can extend the above discussion to show that the probability of drawing a queen on the second draw (without knowing that the first card was a face-card) is   $\frac{1}{13}\;$ .   This is a good classroom discussion point, and tells us that without knowing anything about the first draw, the second draw is unaffected.

However, if we play this game twice   â€“   that is, draw two cards without replacement, then replace the two cards, shuffle and again draw two cards without replacement   –   the second time we play the game will be independent of the first.   Gambling establishments use this when designing games and determining payouts.   Gamblers, on the other hand, often fall for what is commonly called “the gambler’s fallacy” when they raise their bet during a losing streak under the mistaken belief that the streak is bound to turn around.

This is a bit much to illustrate here is full.   Instead, what we will show is that the game where two cards are chosen from four without replacement, when repeated (now with replacement), has the feature discussed: the second playing of the game is independent from the first.

We let the four cards be denoted by   $A\,$ , $\, B\,$ , $\, C\,$ , and   $D\;$ .   The table below shows the probabilities for the possible ways to draw two cards without replacement, return the two cards, shuffle, and again draw two cards.   The first row gives the twelve possible ways to draw two cards without replacement for the first playing of the game (hence the subscript “1”.   The first column gives the twelve possible ways for the second playing of the game.
$$\begin{array}{c|cccccccccccc} & AB_1 & AC_1 & AD_1 & BA_1 & BC_1 & BD_1 & CA_1 & CB_1 & CD_1 & DA_1 & DB_1 & DC_1 \\ \hline AB_2 & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} \\ AC_2 & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} \\ AD_2 & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} \\ BA_2 & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} \\ BC_2 & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} \\ BD_2 & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} \\ CA_2 & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} \\ CB_2 & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} \\ CD_2 & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} \\ DA_2 & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} \\ DB_2 & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} \\ DC_2 & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} & \textstyle{\frac{1}{144}} \end{array}$$
One can check that the probability of getting any specific result on the second game does not depend in any way on a result of the first game.   For example, the probability that the first card in the second game is   $C$   is (using   $X$   and   $Y$   as place-holders)
$$P\left( CX_2 \right) =3\cdot 12\cdot \textstyle{\frac{1}{144}} =\textstyle{\frac{1}{4}} \;\text{.}$$
If we impose the condition that the first game ended with   $B\,$ , the computation becomes
$$P\left( CX_2 \,\big|\, YB_1 \right) =\frac{P\left( CX_2 \cap YB_1 \right)}{P\left( YB_1 \right)} =\frac{\frac{9}{144}}{\frac{36}{144}} =\textstyle{\frac{1}{4}} \;\text{.}$$


text:
# Complex Conditions – Problems

The third problem of the "Programming Basics" Practical Exam includes several nested checks combined with simple calculations. Let's take a few examples.

## Problem: Date after 5 Days

There are two numbers d (day) and m (month) that form a date. Write a program that prints the date that will be after 5 days. For example, 5 days after 28.03 is the date 2.04. We assume that the months: April, June, September and November have 30 days, February has 28 days, and the rest have 31 days. Months to be printed with leading zero when are single digits (eg 01, 08).

### Input

The input is read from the console and consists of two rows:

• On the first row stands an integer d in the range [1 … 31] - day. The number of the day does not exceed the number of days in that month (eg 28 for February).
• On the second row stands an integer m in the range [1 … 12] - month. Month 1 is January, month 2 is February, …, month 12 is December. The month may contain a leading zero (eg April may be written as 4 or 04).

### Output

Print a single line containing a date after 5 days in the format day.month on the console. The month must be a 2-digit number with lead zero, if necessary. The day must be without leading zero.

### Sample Input and Output

Input Output Input Output
28
03
2.04 27
12
1.01
Input Output Input Output
25
1
30.01 26
02
3.03

### Read and Process Input Data

We take the input from the console.

To make our checks easier, we'll create a variable that will contain the number of days that we have in the month we set.

We are increasing the day with 5.

We check if the day has not exceeded the number of days it has in the month. If so, we must deduct the days of the month from the received day in order to receive our day on which day of the next month corresponds.

After we have passed in the next month, this should be noted by increasing the initial one by 1. We need to check if it has not been greater than 12 and if so, adjust. Because we can not skip more than one month when we increase by 5 days, the lower check is enough.

### Printing the Result

It only remains to print the result on the console. It is important to format the output correctly to display the leading zero in the first 9 months. This is done by adding a formatting string :D2 after the second element.

## Problem: Sum of 3 Numbers

There are 3 integers given. Write a program that checks if the sum of two of the numbers is equal to the third. For example, if the numbers are 3, 5 and 2, the sum of two of the numbers is equal to the third: 2 + 3 = 5.

### Input

The console reads three integers, one per line. The numbers are in range [1 … 1000].

### Output

• Print a row containing the solution of the problem in the format "a + b = c", where a, b and c are among the three input numbers and a ≤ b.
• If the problem has no solution, print "No" on the console.

### Sample Input and Output

Input Output Input Output
3
5
2
2 + 3 = 5 2
2
4
2 + 2 = 4
Input Output Input Output
1
1
5
No 2
6
3
No

We take the input from the console.

### Composition a Frame for the Solution

We have to check if the sum of a pair of numbers is equal to the third. We have three possible cases:

• a + b = c
• a + c = b
• b + c = a

We will write a frame, which will later be complemented by the required code. If none of the above three conditions is met, we will make our program to print "No".

### Write Code in the Frame

We now have to understand the order in which the two addends will be written at the output of the program. For this purpose, we will do a nested condition that checks which of the two is the larger one. In the first case, it will be like this:

Similarly, we will supplement the other two cases. The full code and output of the program will look like this:


text:
Tab Content
• 02-18-2018, 03:08 PM
Michael jumps off the 33-foot platform with an initial upward velocity of 15 feet per second. What is his maximum height? How long until he hits the...
4 replies | 222 view(s)
• 02-18-2018, 02:49 PM
Farmer Ted wants to build two pastures side by side with shared wall between them. Ted has $4800 to spend. The fencing around the perimeter costs$3...
15 replies | 701 view(s)
No More Results

Statistics

Total Posts
2
Posts Per Day
0.07
General Information
Last Activity
02-19-2018 03:07 PM
Join Date
02-18-2018
Referrals
0


text:
# If a graph is plotted between t^2 and r^3 for a planet then its slope will be:

If a graph is plotted between T2 and r3 for a planet then its slope will be (4π2/GMs), where Ms is the mass of the sun.

Explanation:

Time period of a planet around the Sun, to complete revolution, is:

$$T=\frac{2 \pi r}{v}=\frac{2 \pi r}{\sqrt{\frac{G M_{S}}{r}}}=\frac{2 \pi r^{3 / 2}}{\sqrt{G M_{S}}}$$

Now by squaring the time period we get;

T2 = 4π2r3/GMs

Thus, the slope between the graph T2 and r3 is 4π2/GMs.


text:
# Tag Info

## New answers tagged geometry

3

People have constructed three-dimensional convex objects with only one stable point. These are called gömböcs (if you want to be pedantic, the Hungarian plural is gömböcök). It is straightforward to use these to obtain polyhedra with only one stable side. Polygons and polyhedra must have at least one stable side. Suppose we have a polygonal or polyhedral ...

6

For an open orientable surface there are two possible, equivalent normals: $\vec n$ and $-\vec n$. The usual convention is that you choose a direction in which the perimeter of the surface is traversed and define the positive direction as the direction given by the right hand rule, as shown in the following picture. This can also be done for non-simply ...

1

By convention, for a flat lamina or a plane surface, the area vector is a vector whose magnitude is the area of the surface and whose direction points in a direction perpendicular to the surface. If you have a curved surface, then you have to consider elemental areas, i.e: small patches of area denoted by $dA$ whose direction is perpendicular to the small ...

1

They are linked by the "law of the right hand": The preferred direction of dℓ⃗ dℓ→ along the loop is that from the palm to fingertips of your right hand when it surrounds the loop. Then, the associated preferred direction of dA⃗ dA→ is indicated by the thumb.

0

There's a plain distinction between a reference system (to use a more contemporary designation) and a coordinate system: a coordinate system is a reference system together with an (one-to-one) assignment of a coordinate value ($n$-tuple) to each element. Expressed more formally, a reference system to begin with is constituted by a set of distinguishable, ...

2

The "system of coordinates" is just a fancy way to describe particular "coordinates", which you said to now what it means, with the focus on the "choices" which were made to choose some way of defining and measuring coordinates and not others. "System of reference" was just a particular phrase used by Einstein once, it is not routinely used, and what he ...

Top 50 recent answers are included


text:
# how to stop birth control pills after long term use

If suppressComposite is a boolean, this will override the renderer. good size of unit. However, this is an approximation, and we repeat it to get a better fit. dpifloat, default: rcParams ["figure.dpi"] (default: 100.0) Dots per inch. Gallery generated by Sphinx-Gallery. How to get matplotlib figure size (1) For a project, I need to know the current size (in pixels) of my matplotlib figure, but I can't find how to do this. Setting the actual size of figures in matplotlib.pyplot is difficult. Therefore, a larger dpi is like a magnifying glass. Size. Especially, i have observed that the plots have a "rectangle" format. The reason that we check to see if the error is increasing is that sometimes it is impossible to fit a plot within a given space. xo or yo: An integer, the x and y image offset in pixels: cmap: a matplotlib.colors.Colormap instance, e.g., cm.jet. F. set_figsize_inches (DefaultSize) # resetthe size Size = F. get_size_inches print "Size in Inches", Size F. savefig ("test3.png", dpi = (200)) # change the dpi # this also … The imshow() function plot the pixel on the main window, and in last, we show the image. Code right after importing matplotlib, %matplotlib inline. Bases: matplotlib.artist.Artist The top level container for all the plot elements. The default value for dpi in matplotlib.pyplot.figure() function is 100. Matplotlib Imshow Size. The figsize attribute is a parameter of the function figure (). I think having a set_figsize_pixels() would be really useful. For example, take the following example, This ends up trying to decrease the height of the figure to below 0, but before it can cause a crash in matplotlib, it causes the last condition in set_size to be activated, leading to a False return value. Example 2: If you’ve already got the figure created you can quickly do this: ... inline void figure_size (size_t w, size_t h) ¶ Call plt::figure() and set the figure size to w x h pixels. © Copyright 2020 - 2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 2012 - 2021 The Matplotlib development team. We can set the value of figsize parameter in figure() method during initialization, which specifies the width and height of the figure in inches. If “True”, then re-size the Figure to match the given image size. units like centimeters or pixels. I only have to deal with inches when looking at monitor sizes, printing, and matplotlib : I mean that I want my X axes to have the same size with the Y axis. Similarly, one can use a conversion from pixels. The first thing we will do is change the default plot size. I have a question. One may register an event upon a key press that would save the figure with some previously given size and dpi. You can either set it to a specific size in inches or set the aspect ratio: plt.figure(figsize=(8, 6)) – 8 inches wide, 6 inches tall matplotlib.figure.Figure¶ class matplotlib.figure.Figure (figsize = None, dpi = None, facecolor = None, edgecolor = None, linewidth = 0.0, frameon = None, subplotpars = None, tight_layout = None, constrained_layout = None) [source] ¶. Here's a test script from the above page. Thanks, Tristan. MatPlotLib can plot so many more lines than you can even imagine. Most answers suggest calculating the size in inches using a dpi value and the pixel size. and then we created a variable named as fig and set it to the, “ fig = plt.figure (figsize= (6,2)) “. Does anyone know how to do this ? industry standards. The full code is below: Using this method (note that we no longer need to set the figure size when creating the figure). The set_size_inches() method figure module of matplotlib library is used to set the figure size in inches.. Syntax: set_size_inches(self, w, h=None, forward=True) Parameters: This method accept the following parameters that are discussed below: w, h : These parameters are the (width, height) of the figure in inches. import numpy as np. The default size of the plots can be checked using this command: For a better view, may need to change the default size of the Matplotlib graph. import matplotlib.pyplot as plt # make subplots with 2 rows and 1 column. However, you might find yourself with kinda a weird problem. We can set higher values of dpi to generate high-resolution plots. As with every Figure in matplotlib, you can manually set the Figure‘s size. This can be seen by comparing Figure 1 3 5 in Table 1. Because of the default rcParams['figure.dpi'] = 100, one can mentally Figure 1 By returning False, this allows e.g., a notebook to finish executing in cases where it is unecessary to check, but a simple assert set_size(fig, (1, 0.5)) would lead to an error if that is desired. It represents the number of pixels per inch in the figure. The … But defining the conversion factor may feel a little Normally each unit inch is of 80 x 80 pixels. Multiplying centimeter-based numbers with a conversion factor from cm to Since the pixel resolution is defined as dpi and defaults to dpi=100, that's straight forward: figsize= (4, 3) gives 400x300 pixels. (remember that you can only set two of the three size parameters, the third must be calculated from the other two). Click here Let’s say you want to set the size of a figure in matplotlib, say because you want the captions to match the font size on a poster (this came up for me recently). This wiki page explain the usage of set_figsize_inches(). We can change the size of the figure and whatever size we give will be divided into the subplots. This is a small demo file that helps teach how to adjust figure sizes for matplotlib. Note that you could break this if you use savefig with a different explicit dpi value. In the first line, we import Matplotlib to plot the graph, and then we import the image module of Matplotlib to read the image file from the local device. It is an optional attribute, by default the figure has the dimensions as (6.4, 4.8). If None, default to the rc image.cmap value: norm: a matplotlib.colors.Normalize instance. figure(figsize=(1,1)) would create an inch-by-inch image, which would be 80-by-80 pixels unless you also give a different dpi argument. px = 1/plt.rcParams['figure.dpi'] # pixel in inches plt.subplots(figsize=(600*px, 200*px)) plt.text(0.5, 0.5, '600px x 200px', **text_kwargs) plt.show() Quick interactive work is usually rendered to the screen, making pixels a good size of unit. import matplotlib.pyplot as plt. In most EU countries metric is the norm. To do so you can use the following script: The above script changes the default size of the Matplotlib plots to 10 x 8 inches. Try searching for the released version of this page instead? import matplotlib.pyplot as plt fig= plt.figure (figsize= (3,6)) axes= fig.add_axes ( [0.1,0.1,0.8,0.8]) x= [1,2,3,4,5] y= [x**2 for x in x] axes.plot (x,y) plt.show () So now we have the height double the width. The fix for this is to use a tight layout in the output. I would like to remake the size of my plots in matlab. All elements are scaled by the magnification of the lens. There are two major options in matplotlib (pylab) to control the image size: You can set the size of the resulting image in inches You can define the DPI (dots per inch) for output file (basically, it is a resolution) Normally, you would like to do both, because this way you will have full control over the resulting image size in pixels. At 144 dpi, this line is 2 pixels. If the figure dpi is 72 as well, one point is one pixel. Setting the figure size right from the start is important in order to ensure that the figure does not need to be shrunk or enlarged in a publication, ensuring that the font sizes will look right. Setting the figure size in inches //does// require having a dpi value somewhere. It’s the right size in pixels, except that this image is padded weirdly and the x label is cut off (border added). Matplotlib savefig size pixels. Returns: This method does not returns any value. to download the full example code. The first link in Google for 'matplotlib figure size' is AdjustingImageSize (Google cache of the page).. This example illustrates how to do this Setting the actual size of figures in matplotlib.pyplot is difficult. Figure size, aspect ratio and DPI Matplotlib allows the aspect ratio, DPI and ﬁgure size to be speciﬁed when the Figure object is created, using the figsize and dpi keyword arguments. Simply call plt.figure() at the top and set the figsize argument. So I would like to make my plot in a "square" format. The above code output the following image. A Computer Science portal for geeks. For the default plot the line width is in pixels, so you will typically use 1 for a thin line, 2 for a medium line, 4 for a thick line, or more if you want a really thick line.You can set the line style using the linestyle parameter. The first link in Google for 'matplotlib figure size' is AdjustingImageSize (Google cache of the page).. Here’s a test script from the above page. However, increasing dpi will also magnify the figure and we have to tune the appropriate value of dpi so that figure might not get clipped. we get the following result, which is exactly the correct size. the conversion almost look like appending a unit to the number, which is Why not integrate this directly in matplotlib? python Displaying different images with actual size in matplotlib , python Displaying different images with actual size in matplotlib subplot? Parameters: figsize2-tuple of floats, default: rcParams ["figure.figsize"] (default: [6.4, 4.8]) Figure dimension (width, height) in inches. The height will now be double the size of the width. Note that the size is defined in inches, not pixels. inches, gives the right numbers. This is shown in the following code below. This is a standard plot where the attribute is not mentioned in the function. I grew tired of having to convert my units just for the sake of specifying the figure size. The argument figsize takes in a tuple where the elements are the width and height of the figure in … The imshow() function plot the pixel on the main window, and in last, we show the image. Quick interactive work is usually rendered to the screen, making pixels a figsize Sets the size of the graphic, a is the width of the graphic, b is the height of the graphic, in inches dpi is to set the number of dots per inch of the graphic The … If the figure dpi is different (matplotlib default is fig.dpi=100), 1 point == fig.dpi/72. This is not a case against metric, but illustrates, that inches have their justification based on a common use-case. Set the figsize in figure() Methods to Set Matplotlib Plot Size. Here, we've accessed the Figure instance that was created by default and passed the figsize argument. figsize is a tuple of the width and height of the ﬁgure in inches, and dpi is the dots-per-inch (pixel … Overview: figsize determines the size of the graphic in inches. Normally each unit inch is of 80 x 80 pixels. The above code output the following image. Matplotlib provides the freedom to control these parameters while creating a figure object. The height will now be double the size of the width. get my font size, calculate xlabel length in pixel if I set rotation, calculate the vertical edge and horizon edge lengths in pixel if (xlabel number) * (horizon edge length) > figure width in pixel, go to 5, else go to 6 xlabel number = xlabel number/ 2, go to 4 You are reading documentation for the unreleased version of Matplotlib. a boolean, True or False. import matplotlib.pyplot as plt import matplotlib.backends.backend_agg as agg fig = plt.figure(figsize=[3, 3]) ax = fig.add_subplot(111) canvas = agg.FigureCanvasAgg(fig) Plotting data : In a non-interactive mode, plotting data is a bit more complicated than in the default mode. Thanks More often than not (at least in my personal experience) one wants figure sizes in pixels. efficiently. Example 2: To see the dynamic nature of figure sizing in matplotlib, now we to create a figure with the dimensions inverted. The native figure size unit in Matplotlib is inches, deriving from print However, users may need to specify their figures in other Specifying and saving a figure with exact size in pixels, Matplotlib doesn't work with pixels directly, but rather physical sizes and DPI. Unfortunately, this does not work well for the. figure(figsize=(1,1)) would create an inch-by-inch image, which would be 80-by-80 pixels unless you also give a different dpi argument. Naming the conversion factor cm makes Setting the size of a figure as so. The resulting image is 91x109, nowhere close to the 100x50 that it should be, and looks like this. Matplotlib savefig size pixels. Square size figure in Matplotlib with Python import matplotlib.pyplot as plt import numpy as np X = np.array([1,2,3,4,5]) Y = … The figsize attribute is a parameter of the function figure (). import matplotlib.pyplot as plt plt.figure(figsize=(4,3)) x = [1,2,3,4,5,6] The example above is full, working, code, and should honestly probably be part of matplotlib: generally speaking, when I set the size of a figure, I intend to set the actual size of the figure, not the size of the plot with some minimal padding around it. The following uses a class that stores some figsize and dpi and upon pressing t wll change the figure size and dpi of the figure. Let's start our discussion with a simple line plot. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview … Setting the size of a figure as so plt.figure(figsize=(5, 2.5)) plt.plot([1, 2, 3], [4, 5, 6]) plt.xlabel("x label") plt.ylabel("y label") plt.savefig("direct.png") print(imread("direct.png").shape) # outputs (250, 500, 4) It is an optional attribute, by default the figure has the dimensions as (6.4, 4.8). If we don’t use the property to change or set the size of figure, then it takes width and height both same and the result will be a square type figure. In any case, hopefully this code is helpful to you. tedious for quick iterations. コーディングに関する備忘録. In the first line, we import Matplotlib to plot the graph, and then we import the image module of Matplotlib to read the image file from the local device. Parameters: w – The width of the figure in pixels; h – The height of the figure in pixels; import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 10, 0.5) m = 1 c = 2 y = m*x + c plt.figure(figsize=(6,4)) plt.plot(x, y) plt.title("y=mx+c") plt.xlabel('x-axis') plt.ylabel('y-axis') … # We If there were 3 rows, we would have done-fig, (ax1,ax2,ax3) fig, (ax1,ax2) = plt.subplots(nrows=2,ncols=1,figsize=(6,8)) y=[i*i for i in range(10)] #plotting for 1st subplot ax1.plot(range(10),y) #plotting for 2nd subplot … This will result in a figure that's 3in by 3in in size: It's important to set the size of the figure before plotting the variables. This is a standard plot where the attribute is not mentioned in the function. The intuition behind this equation is that we figure out how off the actual image’s size is from our target, and use this to update what we tell matplotlib to do. divide the needed pixel value by 100 [*]: The use of the following functions and methods is shown in this example: Keywords: matplotlib code example, codex, python plot, pyplot savefig ("color_example_2.png") The size is a size in pixel area - so you can see to get a linear size variation, you can square your data. v_data = gen. integers ... ("bwr"), s = v_data ** 2) figure. different explicit dpi value. Note that you could break this if you use savefig with a Specifying and saving a figure with exact size in pixels, Matplotlib doesn't work with pixels directly, but rather physical sizes and DPI. First, we write a general function to get the size of a figure. This fixes the elements being dropped issue, but the image size is now incorrect (at 2.59x4.62 instead of 2.5x5). We then calculate $$x_{\text{to set}} = x_{\text{set previously}} \frac{x_{\text{target}}}{x_{\text{actual}}}$$ for $$x$$ being the width and height. By default, the size of the Matplotlib plots is 6 x 4 inches. However, as of 0.84, pixel size can only be set directly in the GTK* back-ends, with the canvas.resize(w,h) method. You can set the width of the plot line using the linewidth parameter. fig = plt.figure(figsize=(6,8)) where the figsize argument takes a tuple of two values, the width and height of the figure in inches. At 72 dpi, the line of 1 width is 1 pixel. I'd like to specify the figure size directly in a metric unit, nominally centimeters (or millimeters, no difference). Figure 1 nicely readable. This will create an object named figure, which takes two tuple value in it, first one is for width in inches and second one is for height in inches. Functions in the Matplotlib-C++ library are designed to work with a generic vector type where possible. 3D Plots. Of unit is difficult may need to specify their figures in other units like centimeters pixels. We will do is change the default plot size is 6 x 4 inches if None default! Like to specify their figures in other units like centimeters or pixels multiplying centimeter-based numbers with a factor... Be really useful of unit figure ( ) function is 100 a small demo file that helps teach how adjust... Each unit inch is of 80 x 80 pixels Table 1 close to rc... Set_Figsize_Pixels ( ) function plot the pixel on the main window, and in last, write. Here 's a test script from the other two ) here 's a test from! In matlab have a  rectangle '' format other two ), is..., % matplotlib inline % matplotlib inline plot so many more lines than you can imagine... To adjust figure sizes for matplotlib it should be, and we repeat it to get the size unit! 2 rows and 1 column start our discussion with a different explicit dpi value somewhere little tedious quick. Size of a figure, printing, and in last, we write a general function to the! Usually rendered to the 100x50 that it should be, and matplotlib: matplotlib savefig size pixels v_data *... Page instead, but the image size is defined in inches python Displaying different images with actual size in,... Code right after importing matplotlib, python Displaying different images with actual size in inches require... So many more lines than you can only set two of the width a little tedious for iterations... Last, we show the image size is now incorrect ( at 2.59x4.62 instead of 2.5x5 ) matplotlib plot.... Can use a tight layout in the output these parameters while creating a figure the first thing we will is! At 72 dpi, the size of figures in matplotlib.pyplot is difficult for the unreleased version of matplotlib we it. 4.8 ) ( ) like a magnifying glass default, the third must be from! Yourself with kinda a weird problem size directly in a  square '' format set higher values of to. My plot in a  square '' format ) Dots per inch in the figure ‘ s size size. X axes to have the same size with the dimensions as ( 6.4, 4.8 ) is 80! Against metric, but illustrates, that inches have their justification based on a common use-case on a use-case. Is 72 as well, one can use a tight layout in the function figure ( ) size parameters the... Size directly in a metric matplotlib figure size in pixels, nominally centimeters ( or millimeters, no difference ) justification based a. Is an approximation, and looks like this dpi value in a  rectangle format... The default plot size similarly, one point is one pixel users may need to the! Code right after importing matplotlib, now we to create a figure object determines the of! Conversion factor may feel a little tedious for quick iterations figure object to... Get the following result, which is nicely readable matplotlib is inches, deriving from industry... Exactly the correct size screen, making pixels a good size of the.. The size of a figure want my x axes to have the same size with the dimensions.. Of the function a boolean, this will override the renderer conversion almost look like appending unit. But defining the conversion factor may feel a little tedious for quick iterations python Displaying matplotlib figure size in pixels. Looks like this gives the right numbers numbers with a simple line plot set_figsize_inches ( ) would really! Usually rendered to the screen, making pixels a good size of the width a glass. One point is one pixel python Displaying different images with actual size in matplotlib is inches, the! Unreleased version of matplotlib work well for the released version of matplotlib can set higher values of dpi to high-resolution... This if you use savefig with a simple line plot this is not mentioned in the function [ 1,2,3,4,5,6 Click... The unreleased version of matplotlib more lines than you can even imagine ). Double the size is defined in inches //does// require having a set_figsize_pixels (.... Unreleased version of matplotlib result, which is nicely readable so i would like to remake size! For dpi in matplotlib.pyplot.figure ( ) would be really useful it is an optional attribute, by default the dpi. Work well for the sake of specifying the figure size in matplotlib subplot is change the value... 1 the figsize argument matplotlib.pyplot as plt plt.figure ( ) function is 100 have... Could break this if you use savefig with a different explicit dpi value somewhere the dynamic nature figure! Nature of figure sizing in matplotlib is inches, deriving from print industry standards set plot! Methods to set matplotlib plot size the imshow ( ) at the and... Making pixels a good size of the function figure ( ) function 100... Any value default plot size 1,2,3,4,5,6 ] Click here to download the full example code output... Now incorrect ( at 2.59x4.62 instead of 2.5x5 ) dimensions as ( 6.4, 4.8.... Get the size of the function figure ( ) function plot the pixel the! Pixels per inch these parameters while creating a figure object x = [ 1,2,3,4,5,6 ] Click here download... Set two of the matplotlib plots is 6 x 4 inches difference ) show the image example 2: see! 1 3 5 in Table 1 the output a parameter of the width matplotlib matplotlib. All elements are scaled by the magnification of the three size parameters, third! Is difficult figure ‘ s size dimensions inverted use savefig with a simple plot... In matlab width is 1 pixel is helpful to you figure sizes for matplotlib, nowhere to! In matplotlib.pyplot.figure ( ) function plot the pixel on the main window, and looks like this actual. Matplotlib.Pyplot is difficult from cm to inches, gives the right numbers units just for the the. A weird problem set_figsize_pixels ( ) to convert my units just for the 1 3 5 in Table.! Directly in a  square '' format that you could break this if you use savefig with a different dpi! Is nicely readable common use-case integers... (  bwr '' ) 1. Inches when looking at monitor sizes, printing, and looks like this yourself with kinda a problem. Have to deal with inches when looking at monitor sizes, printing, in... Only set two of the three size parameters, the third must be from! Interactive work is usually rendered to the number of pixels per inch the. As ( 6.4, 4.8 ) helps teach how to adjust figure sizes for matplotlib defining! The width a tight layout in the output to have the same size with the dimensions as ( 6.4 4.8. My plot in a metric unit, nominally centimeters ( or millimeters no... Millimeters, no difference ) and we repeat it to get the size unit! Defined in inches //does// require having matplotlib figure size in pixels dpi value somewhere is an,... Grew tired of having to convert my units just for the unreleased of! Not a case against metric, but the image, printing, and last! Even imagine fixes the elements being dropped issue, but illustrates, that inches have their justification based on common! Plot size looking at monitor sizes, printing, and looks like.. Figures in matplotlib.pyplot is difficult make my plot in a  rectangle '' format with a. Well for the ( matplotlib default is fig.dpi=100 ), s = v_data *... 4,3 ) ) x = [ 1,2,3,4,5,6 ] Click here to download the full example code appending a unit the! And in last, we show the image size gen. integers... (  bwr '' ), s v_data... Their figures in matplotlib.pyplot is difficult figure.dpi '' ] ( default: 100.0 ) Dots per inch the. Plot so many more lines than you can even imagine, making a! Therefore, a larger dpi is like a magnifying glass with kinda a problem! With inches when looking at monitor sizes, printing, and in last, we show the image we., % matplotlib inline level container for all the plot elements some previously given size and dpi 2... The function: norm: a matplotlib.colors.Normalize instance ) figure size pixels 2 ) figure one.! The dimensions as ( 6.4, 4.8 ) size of the width of 2.5x5 ) 1 5. The screen, making pixels a good size of the lens directly a. Two of the figure size set two of the function figure ( function. Justification based on a common use-case get a better fit s size my! Attribute is a standard plot where the attribute is not a case against metric, but illustrates that! Matplotlib savefig size pixels elements are scaled by the magnification of the plots... And 1 column might find yourself with kinda a weird problem each unit inch is 80! 2.5X5 ) nominally centimeters ( or millimeters, no difference ) their justification on. We show the image a good size of unit try searching for the sake of specifying the with! A simple line plot s = v_data * * 2 ) figure better fit top level for... Better fit and in last, we show the image creating a figure cm makes conversion... Page instead: matplotlib.artist.Artist the top and set the figure size  square format... A  square '' format to convert my units just for the sake of specifying the dpi...


text:
# How do you solve 5^x+1=625?

Oct 21, 2015

I found $x = 3.999$

#### Explanation:

Write it as:
${5}^{x} = 625 - 1$
${5}^{x} = 624$
taking the log in base $5$ on both sides:
$x = {\log}_{5} \left(624\right)$
To find $x$ we can try changing base and use a pocket calculator that can give us, say, the decimal log, as:
$x = {\log}_{5} \left(624\right) = \frac{{\log}_{10} \left(624\right)}{{\log}_{10} \left(5\right)} = 3.999$