2021-06-05 Python stats

image.png
# -*- coding: utf-8 -*-
"""
Created on Sat Jun  5 05:17:04 2021

@author: Quan Wang(Sunny)
"""

import scipy.stats as stats
import numpy as np
import matplotlib.pyplot as plt

nor = stats.norm

x= np.linspace(-8,7,150)
mu =(-2,0,3)
tau =(.7,1,2.8)
colors =["#348ABD","#A60628", "#7A68A6"]

parameters = zip(mu,tau,colors)

for _mu, _tau, _color in parameters:
    plt.plot(x, nor.pdf(x, _mu, scale = 1./_tau), label= "$\mu= %d,\;\\tau=%.lf$"%(_mu, _tau), color=_color)
    plt.fill_between(x, nor.pdf(x, _mu, scale=1./_tau), color =_color, alpha=.33)

plt.legend(loc = "upper left")
plt.xlabel("$x$")
plt.ylabel("density function at $x$")
plt.title("Probability distribution of three different Normal Distribution random variable")
image.png
# -*- coding: utf-8 -*-
"""
Created on Sat Jun  5 04:08:43 2021

@author: Quan Wang(Sunny)
"""

import numpy as np 
import matplotlib.pyplot as plt


def logistic(x, beta):
    return 1.0/(1.0 + np.exp( beta*x))

x = np.linspace(-4,4,100)
plt.plot(x, logistic(x,1), label = r'$\beta = 1$')
plt.plot(x, logistic(x,3), label = r'$\beta = 3$')
plt.plot(x, logistic(x,-5), label = r'$\beta = -5$')
plt.legend()

你可能感兴趣的:(2021-06-05 Python stats)