Programming Basics and Statistical Distributions in Python

lab session for stochastic processes n.w
1 / 21
Embed
Share

Discover the essentials of programming with Python, including fundamental concepts like variables and libraries. Learn about statistical distributions such as normal, uniform, and Bernoulli. Get started with basic Python commands and explore generating Bernoulli random variables.

  • Python Basics
  • Statistical Distributions
  • Programming Concepts
  • Bernoulli Distribution
  • Python Libraries

Uploaded on | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Lab Session for Stochastic Processes Session 1 BY AYESHA AHMAD

  2. what is programming? Understanding the problem What you have and what you need? Making an algorithm (mental map) Variables what (computer understandable) steps do you need to take/do Results Writing the code python

  3. Starting with Python Open Launch SPYDER

  4. Libraries Discuss concept of libraries: a Python library is simply a collection of codes or modules of codes that we can use in a program for specific operations Example import numpy as np import math

  5. Very Basic Example How to multiply two numbers?

  6. A Brief Introduction to some basic python commands Declaring/Creating variable Variables are containers for storing data values. Unlike other programming languages, Python has no command for declaring a variable. A variable is created the moment you first assign a value to it. Example: x=5, Y=5.2

  7. Continued

  8. Continued DISPLAY: Print( value of A ,A) LOOP: for i in range (start,stop): Indentation is imp

  9. What is a statistical distribution? It is a mathematical description of a random phenomenon in terms of its sample space and the probabilities of events Normal Distribution Uniform distribution Binomial Distribution

  10. What is Bernouli Distribution Discrete distribution Of random variable which takes the value 1 with probability p and the value 0 with probability q=p-1 Let p=1/2 then q=1/2

  11. Code To Generate Bernouli RV Understanding the problem Starting point: uniform Random variable Uniform Random Variable: a number from range [0,1] With each real number between zero having an equal chance of occurring Bernouli Random Variable: either one or zero With both having equal probability i.e. 0.5 To generate RV we will need to generate around 1000 individual samples

  12. What we need to do? We need Bernoulli RV X Generate Uniform Random Variable say u If u is less than 0.5 then let X=0 if u is greater than 0.5 then X=1 Repeat for 1000 times and get array X[1000] Plot histogram of X

  13. What is Binomial Distribution The Binomial Distribution represents the number of successes and failures in n independent Bernoulli trials for some given value of n HW p=0.5

  14. Code to generate Exponential RV Understanding the problem Starting point: uniform Random variable Uniform Random Variable: a number from range [0,1] With each real number between zero having an equal chance of occurring Exponential Random Variable: If u is a rand uniform variable Then log 1 ? is exponential random variable To generate RV we will need to generate around 10000 individual samples

  15. What we need to do We need a exponential RV X Generate Uniform Random Variable say u Calculate x = log 1 ? Repeat for 1000 times and get array X[1000] Plot histogram of X

Related


More Related Content