Posts

Showing posts from November 22, 2018

Polar form of normal random vector , angle and length are independent ,and angle is spherical distribution

Image
up vote 1 down vote favorite Represent $g sim N(0,I_n)$ in polar form as $g=r theta$ where $r = |g|_2$ is the length and $theta = frac{g}{|g|_2} $ is the direction prove that $r$ and $theta$ are independent ? prove that $theta$ is uniformly distributed on sphere $S^{n-1}$ for first one : The only things I know how to do is to show the product pdf of both of $theta$ and $r$ is same as n-dimeinal pdf of of standard Gaussian vector ? but how to find pdf of $|g|_2$ ? I have some problem in trasformation of random variable in this case . since the transformationare not bijective , is any simple way to do that? probability probability-theory random-variables normal-distribution independence share | cite | improve

Assign return value from python method to a variable in bash script

Image
up vote 0 down vote favorite From a shell script, I am executing python program. I am trying to assign the return value from python to a variable in shell script and comparing this variable in if else condition. I don't know where I made a mistake either in code or some syntax. Please help me getting the correct output. test.sh #!bin/sh #!/usr/bin/python2.7 password="Testing@2134testing" password_check=$(python password.py $password) if [ "$password_check" == "True" ];then echo "Correct" else echo "Incorrect" fi password.py import re, sys password = sys.argv[1] def passwordCheck(): if re.match(r'(?=.*[A-Z])(?=.*[0-9])(?=.*[a-z])(?=.*[^A-Za-z0-9]).{14,}', password): return True; else: return False; Eve