1 minute read

Powershell, Common Probability Distributions.

Learned how to do some basic powershell scripting. Setup and played around with different consoles/terminals on top of my powershell 7.0.0 shell. Tried out hyper and deleted it, didnt like it, didnt like the electron either. Playing around with ConEmu now, seems to be working fine so far. I was using marktext to edit my TIL files and it shows a bunch of deprecated electron errors to my terminal which I silenced by redirecting the output to “NUL”. the current state of my powershell profile is this:

function blog
{
    cd ~\repositories\translucent504.github.io
}

function til
{    
    $mark = "C:\Users\ERU\AppData\Local\Programs\Mark Text\Mark Text.exe"
    $date = get-date -f yyyy-MM-dd-ddMMMyy
    $filename = "C:\Users\ERU\repositories\translucent504.github.io\_posts\$date.md"
    if (!(test-path $filename))
    {
        cp 'C:\Users\ERU\repositories\translucent504.github.io\_posts\template.md' $filename
    }
    start $mark $filename -redirectstandardoutput "NUL"
}

function uptil
{
    blog
    git add .
    git commit -m "Updated TIL"
    git push
    cd -
}

Bernoulli distribution is basically binary trials where the random variable X takes the value 0 or 1 for a positive or negative outcome. Given the probability of a positive outcome (X=1) is p. The Expected value of X: \(E(X) = p(1) + (1-p)(0) = p\) and the variance is \(Var(X)=E(X)^2 - E(X^2) = p^2-p = p(1-p)\)

If we consider n bernoulli trials and consider X to be the random variable of having a success / positive outcome on the x’th trial then we get a binomial distribution. The PMF (Probability Mass Function) for Bernoulli is \(P(x) = x*p + (1-p)(1-x)\) . The PMF for the Binomial is \(P(X)= {n\choose x}p^x (1-p)^{(n-x)}\) . Then we have the standard normal distribution with a Gaussian PDF.

The Poisson distribution applies to cases where we want to check counts of some independent events in a given interval. It has both \(E(X) = Var(X)= \lambda\)