Sei sulla pagina 1di 29

DEPARTAMENTO DE ELÉCTRICA Y

ELECTRÓNICA

Carrera de Ingenierı́a en Electrónica y Telecomunicaciones


Carrera de Ingenierı́a en Electrónica, Automatización y Control

LABORATORIO DE PROCESOS ESTOCÁSTICOS

GUÍA DE PRÁCTICAS

Dr. Enrique V. Carrera

SANGOLQUÍ, ECUADOR
2018
Guı́a de Prácticas del Laboratorio de
Procesos Estocásticos

INTRODUCCIÓN

Propósito de las prácticas

Familiarizar al estudiante con las diversas herramientas matemáticas de análisis y modelado


de procesos aleatorios mediante el uso del software Matlab. En las seis prácticas de laboratorio
preparadas se procederá a:

Entender el proceso de conteo y muestreo.


Utilizar los conceptos de probabilidades y teorema de Bayes.
Simular los procesos de Poisson y Markov.
Trabajar con la distribución de Poisson.
Modelar un canal binario de comunicación.
Determinar la confiabilidad de un sistema.

Desarrollo de las prácticas

Las prácticas serán desarrolladas por los estudiantes después de haber revisado la guı́a co-
rrespondiente y realizado el trabajo preparatorio. El trabajo preparatorio es individual y será
verificado antes de la realización de la práctica.
Las prácticas podrán realizarse en grupo de máximo 2 estudiantes y deberán participar
todos sus integrantes sin excepción. Cada grupo deberá anticiparse en disponer de todos los
elementos/requisitos necesarios para la ejecución de cada práctica.
Se entregará un informe de cada práctica en un plazo no mayor a 8 dı́as a través de la
plataforma de aula virtual utilizada. El informe debe ser subido a la plataforma en formato
PDF y será defendido en forma individual en la próxima sesión de laboratorio.

Presentación de informes

Los informes deberán ser presentados en el formato de un artı́culo técnico de acuerdo a


las normas establecidas en los IEEE Conference Proceedings Templates (http://www.ieee.
org/conferences_events/conferences/publishing/templates.html). Las secciones que se
recomiendan incluir en todos los informes son:

1. Tı́tulo de la práctica
2. Autores y filiación
3. Resumen (Visión general en menos de 200 palabras)
4. Introducción (Fundamento teórico, motivación y objetivos)
5. Métodos y materiales (En caso de aplicar)
6. Procedimiento de la práctica (Proceso, componentes, código, funcionalidad, etc.)
7. Resultados y análisis (Usar anexos en caso de ser necesario)
8. Conclusiones y recomendaciones
9. Bibliografı́a
10. Anexos (En caso de requerirlo)

1
Rúbrica de calificación

Desempeño
Actividad
Excelente Bueno Regular Malo
Trabajo Conoce detalles Conoce solo Apenas conoce No realizó el
preparatorio del trabajo generalidades el tema preparatorio
(6 puntos) (4 puntos) (2 puntos) (0 puntos)
Informe de la Informe incluye Informe incluye Informe incluye No presentó el
práctica todas las sec- todas las acti- secciones y acti- informe
ciones y activi- vidades pero no vidades en for-
dades secciones ma parcial
(7 puntos) (5 puntos) (3 puntos) (0 puntos)
Presentación Conoce detalles Conoce solo Apenas conoce No realizó la
de la práctica generalidades el tema práctica
(7 puntos) (5 puntos) (3 puntos) (0 puntos)

Recomendaciones

Los estudiantes deben tener cuidado durante la manipulación de equipos e instrumentos.


Antes de utilizar los equipos deben reportar cualquier inconveniente que presenten los
mismos.

El comportamiento de los estudiantes debe obedecer a las normas de convivencia usadas


en cualquier salón de clases. Eso incluye el ingreso puntual al laboratorio y la prohibición
de consumo de alimentos o bebidas.

2
UNIDAD 1
GUÍA DE PRÁCTICA No. 1.1

1. Tema
Introducción al conteo y muestro en juegos de azar.

2. Fecha lı́mite de entrega


Ver la planificación semestral en http://vinicio.url.ph/.

3. Documentación a entregar
El informe de cada grupo en formato PDF a través de la plataforma informática.

4. Objetivos
Familiarizar al estudiante con los procesos de conteo y muestro en procesos aleatorios
mediante el uso de Matlab.
Entender la funcionalidad de los diversos comandos existentes en Matlab para el modelado
de juegos de azar.

5. Materiales
Computador con software Matlab instalado.

6. Procedimiento
Realizar las actividades listadas en el Anexo 1 de esta guı́a.

7. Preguntas
Describir los comandos principales disponibles en Matlab para la generación de números
aleatorios.

8. Bibliografı́a
1. Athanasios Papoulis. Probability, Random Variables and Stochastic Processes, 4th Edition.
McGraw-Hill, ISBN 978-0071226615, 2002.
2. Hwei P. Hsu. Schaum’s Outline of Theory and Problems of Probability, Random Variables,
and Random Processes, 2nd Edition. McGraw Hill, ISBN 0-07-030644-3, 2011.

3
UNIDAD 1
GUÍA DE PRÁCTICA No. 1.2

1. Tema
Cálculo de probabilidades y el teorema de Bayes.

2. Fecha lı́mite de entrega


Ver la planificación semestral en http://vinicio.url.ph/.

3. Documentación a entregar
El informe de cada grupo en formato PDF a través de la plataforma informática.

4. Objetivos
Familiarizar al estudiante con el cálculo de probabilidades y uso del teorema de Bayes en
Matlab.
Entender la funcionalidad de los diversos comandos existentes en Matlab para la determi-
nación de probabilidades.

5. Materiales
Computador con software Matlab instalado.

6. Procedimiento
Realizar las actividades listadas en el Anexo 2 de esta guı́a.

7. Preguntas
Describir los comandos principales disponibles en Matlab para el cálculo de probabilidades.

8. Bibliografı́a
1. Athanasios Papoulis. Probability, Random Variables and Stochastic Processes, 4th Edition.
McGraw-Hill, ISBN 978-0071226615, 2002.
2. Hwei P. Hsu. Schaum’s Outline of Theory and Problems of Probability, Random Variables,
and Random Processes, 2nd Edition. McGraw Hill, ISBN 0-07-030644-3, 2011.

4
UNIDAD 2
GUÍA DE PRÁCTICA No. 2.1

1. Tema
Modelado de los procesos de Poisson y Markov.

2. Fecha lı́mite de entrega


Ver la planificación semestral en http://vinicio.url.ph/.

3. Documentación a entregar
El informe de cada grupo en formato PDF a través de la plataforma informática.

4. Objetivos
Familiarizar al estudiante con la utilización de los procesos de Poisson y Markov en Matlab.
Entender la funcionalidad de los diversos comandos existentes en Matlab para el modelado
de los procesos de Poisson y Markov.

5. Materiales
Computador con software Matlab instalado.

6. Procedimiento
Realizar las actividades listadas en el Anexo 3 de esta guı́a.

7. Preguntas
Describir los comandos principales disponibles en Matlab para el modelado de los procesos
de Poisson y Markov.

8. Bibliografı́a
1. Athanasios Papoulis. Probability, Random Variables and Stochastic Processes, 4th Edition.
McGraw-Hill, ISBN 978-0071226615, 2002.
2. Hwei P. Hsu. Schaum’s Outline of Theory and Problems of Probability, Random Variables,
and Random Processes, 2nd Edition. McGraw Hill, ISBN 0-07-030644-3, 2011.

5
UNIDAD 2
GUÍA DE PRÁCTICA No. 2.2

1. Tema
Análisis de los procesos de Poisson.

2. Fecha lı́mite de entrega


Ver la planificación semestral en http://vinicio.url.ph/.

3. Documentación a entregar
El informe de cada grupo en formato PDF a través de la plataforma informática.

4. Objetivos
Familiarizar al estudiante con el análisis de los denominados procesos de Poisson en Matlab.
Entender la funcionalidad de los diversos comandos existentes en Matlab para el análisis
de los procesos de Poisson.

5. Materiales
Computador con software Matlab instalado.

6. Procedimiento
Realizar las actividades listadas en el Anexo 4 de esta guı́a.

7. Preguntas
Describir los comandos principales disponibles en Matlab para el análisis de los procesos
de Poisson.

8. Bibliografı́a
1. Athanasios Papoulis. Probability, Random Variables and Stochastic Processes, 4th Edition.
McGraw-Hill, ISBN 978-0071226615, 2002.
2. Hwei P. Hsu. Schaum’s Outline of Theory and Problems of Probability, Random Variables,
and Random Processes, 2nd Edition. McGraw Hill, ISBN 0-07-030644-3, 2011.

6
UNIDAD 3
GUÍA DE PRÁCTICA No. 3.1

1. Tema

Simulación de un canal de comunicación binario.

2. Fecha lı́mite de entrega

Ver la planificación semestral en http://vinicio.url.ph/.

3. Documentación a entregar

El informe de cada grupo en formato PDF a través de la plataforma informática.

4. Objetivos
Familiarizar al estudiante con la simulación de sistemas similares a un canal de comunica-
ción binario en Matlab.
Entender la funcionalidad de los diversos comandos existentes en Matlab para la simulación
de sistemas aleatorios.

5. Materiales
Computador con software Matlab instalado.

6. Procedimiento
Realizar las actividades listadas en el Anexo 5 de esta guı́a.

7. Preguntas
Describir los comandos principales disponibles en Matlab para la simulación de sistemas
aleatorios.

8. Bibliografı́a
1. Athanasios Papoulis. Probability, Random Variables and Stochastic Processes, 4th Edition.
McGraw-Hill, ISBN 978-0071226615, 2002.
2. Hwei P. Hsu. Schaum’s Outline of Theory and Problems of Probability, Random Variables,
and Random Processes, 2nd Edition. McGraw Hill, ISBN 0-07-030644-3, 2011.

7
UNIDAD 3
GUÍA DE PRÁCTICA No. 3.2

1. Tema
Determinación de la confiabilidad de un sistema.

2. Fecha lı́mite de entrega


Ver la planificación semestral en http://vinicio.url.ph/.

3. Documentación a entregar
El informe de cada grupo en formato PDF a través de la plataforma informática.

4. Objetivos
Familiarizar al estudiante con parámetros aleatorios como la confiabilidad de un sistema
en Matlab.
Entender la funcionalidad de los diversos comandos existentes en Matlab para el cálculo
de la confiabilidad de un sistema.

5. Materiales
Computador con software Matlab instalado.

6. Procedimiento
Realizar las actividades listadas en el Anexo 6 de esta guı́a.

7. Preguntas
Describir los comandos principales disponibles en Matlab para determinar la confiabilidad
de un sistema.

8. Bibliografı́a
1. Athanasios Papoulis. Probability, Random Variables and Stochastic Processes, 4th Edition.
McGraw-Hill, ISBN 978-0071226615, 2002.
2. Hwei P. Hsu. Schaum’s Outline of Theory and Problems of Probability, Random Variables,
and Random Processes, 2nd Edition. McGraw Hill, ISBN 0-07-030644-3, 2011.

8
ANEXOS

9
Anexo 1. Counting, Sampling, and Games in Matlab1
1. Introduction
In this lab, we will study counting experiments and demonstrate how they relate to random
sampling from a set. These ideas will be used to examine some of the games that people play. As
with most problems in engineering, you will be required to do some mathematical reasoning and
then verify your results using a software tool. For this class, that software tool will be Matlab.

2. Counting and Sampling


The purpose of counting in probability theory is to determine the numbers of ways an
experiment can turn out. For example, in a 42-number lottery, there are 5245768 ways for the
State to pick the 6 winning numbers from a hat containing 42. We shall prove this.
If you think about it, the State draws little plastic markers labeled with numbers. That is, the
State uses integers to code the objects of the experiment. This is a matter of convenience. Even
football teams use numbers on jerseys to code their human participants. As we shall see, the
integer coding of objects in an experiment simplifies the description. It will not matter whether
the objects are people or playing cards.
Because there is a game to illustrate every counting principle, we can study the classical
counting formulas by studying games.

2.1. Sampling with and without replacement


Consider the drawing of numbers from a hat containing the numbers 1 through n. The first
draw produces a number of which there are n possible. If the drawn number is placed back into
the hat and a second number is drawn (out of a possible n numbers), then there are n2 possible
ways that the experiment can turn out. If this number is placed back into the hat and the
experiment continues until r numbers have been drawn, then the number of possible outcomes
for the experiment is N = nr . We call this experiment ‘sampling with replacement.’
Now suppose r numbers are drawn from a hat without replacement. The first draw produces
one of n possible outcomes, the second produces one of n − 1 possible outcomes, and so on. The
n!
number of possible outcomes for r such draws is N = (n)r = (n−r)! . We call this experiment
‘sampling without replacement.’
If we again consider the experiment where we draw numbers from a hat containing n numbers,
then permutations depend on the order of the numbers drawn. On the other hand, if we are
interested in the number of r number combinations that may be drawn from the n number hat,
then we need to remove the multiplicity of each combination, namely nk = (n) n!
 r
r! = r!(n−r)! .

2.2. Counting and sampling in Matlab


The are four main functions that you will need for this lab. The first two are built-in Matlab
functions for doing permutations and combinations, and the last two are home-brewed functions
that you can use to perform sampling without replacement and to count the number of element
matches between two vectors.
The permutation function in Matlab is perms. You pass it a vector and it returns all of the
permutations of the vector. To see this try typing perms(1:4) or even perms(’abcd’). If you do
not like the order of the results, you can try either perms(4:-1:1) or sortrows(perms(1:4)).
1
Material based on the course Introduction to Communications Principles from Colorado State University

10
Another useful function in Matlab for being used in this lab is randperm. For instance,
randperm(n,k) returns a row vector containing k unique integers selected randomly from 1 to
n inclusive.
There is one function that both computes the value of nk and returns all of the combinations


of length k, namely nchoosek(n,k). This function takes two inputs. When the first input is a
single number, the output is the numerical value of nk . When the first input is a vector of
n

length n, then nchoosek returns the k combinations of the n numbers 1 through n, taken k
at a time. To see this, type nchoosek(5,3) to see that there are 10 combinations of 5 elements
taken 3 at a time. To see the actual combinations, type nchoosek(1:5,3).

2.3. Sampling without replacement in Matlab


For sampling without replacement, create the function pick nums.m. This function must
randomly draw without replacement k numbers from a set of n numbers. To verify this, try
typing pick nums(1:12,3) or pick nums(1:42,6) many times over.
The last function to create is count matches.m, which takes in two vectors and counts the
number of elements they have in common without regard for the position of the elements in
their respective vectors. For example, the vector [147] has 2 matches with the vector [734]. The
two vectors do not need to be the same length. An example of this that uses count matches is

State = pick nums(1:60,20);


player = pick nums(1:60,10);
num matches = count matches(State, player)

When this last function is called with only one return variable (num matches above), it only
returns the number of matches. If you want to see which values are actually matched, you can
replace the last line with

[num matches values matched] = count matches(State,player)

3. Lotto
Lotto is a game where each player chooses K unique numbers out of a possible N numbers
until the State closes the game. At that point, the State picks its own K unique numbers and
then pays each player based on the number of correctly matched numbers.
In a hypothetical Lotto game, let there be N = 42 possible numbers. Each player (and hence
the State) chooses K = 6 numbers. This means that there are 42

6 = 5245786 possible ways to
choose 6 numbers from 42 possible numbers. Therefore, the odds of matching all 6 numbers is
5245786 to 1. But what are the odds of matching, say, only 4 numbers. To see this, break the 42
possible numbers into a desired set of 6 numbers and the unwanted set of 36 numbers. If a player
matches 4 of the desired numbers, then the player also matches 2 numbers from the unwanted
set. Therefore, the total number of combinations of 4 desired numbers and 2 unwanted numbers
is 64 36
 
2 = 9450. This means that the odds of matching exactly 4 numbers is 5245786 to 9450,
which is approximately 555 to 1. In general, there are
  
6 42 − 6
k 6−k

ways to match k = 0, 1, . . . , 6 numbers in a (42, 6) Lotto. The odds of matching k numbers is just
the number of possible outcomes vs. the number of outcomes that produce k matches, namely

11
42 6 42−6
  
6 to k 6−k . The ‘inverse of odds’ is the probability of k matches
6 42−6
 
k 6−k
P (k; 42, 6) = 42
 ; k = 0, 1, . . . , 6.
6

There are two functions that you need to create for simulating a Lotto game. The first one,
namely lotto game.m, must play a Lotto game with M players and returns the draw that the
state made along with player draws and their respective matches. To use this function, you have
define three values: N = total possible numbers, k = number of draws for each player, and M =
number of players. For example, if you type

lotto game(42,6,5)

the result could be

State =
35 2 25 41 12 37
player data =
5 3 12 40 4 14 1
42 9 21 13 29 40 0
33 28 6 4 1 14 0
35 42 1 33 25 22 2
11 35 12 32 28 8 2

In the player data matrix, the last column contains the number of matches that the player
got.
The second function to create is lotto histo.m, which plays a Lotto game with M players
and plots the measured and theoretical statistics for the game. To see this, you must type the
following:

[est pmf act pmf] = lotto histo(42,6,10)

3.1. Advanced Lotto – Optional


Powerball is a Lotto game where each player picks 5 unique numbers between 1–55 and
then one Powerball number between 1–42. The State does the same. How many possible ways
are there to create a six digit Powerball number? How many possible ways are there to match
0 ≤ k ≤ 5 of the first five numbers correctly and match the Powerball number correctly? How
many possible ways are there to get 0 ≤ k ≤ 5 of the first five numbers correctly and match the
Powerball number incorrectly?
Create versions of lotto game.m and lotto histo.m for Powerball. For the lotto game.m
program, create two probability graphs: one for matching the first 5 numbers when the Power-
ball matches and one for matching the first 5 numbers when the Powerball does not match.
Then, create a third graph that has the probability of matching 0, 1, . . . , 6 numbers (i.e., do
not distinguish between matching one of the five numbers and matching one of the Powerball
numbers.
Matching the Powerball counts as matching one of the six numbers. How do the odds of
matching numbers in Powerball compare to matching numbers in (42, 6) Lotto? That is, com-
pare the theoretical probabilities used in the third plot from this problem with the theoretical
probabilities for a (42, 6) Lotto.
(Hint: When you are counting the number of matches for the first two graphs, you want
to make sure that you are only counting matches when the Powerball is correct/incorrect. One

12
way to do this is to set up a vector of length M that is one when the Powerball matches and
zero otherwise. Then, you can use find on this vector to select the correct indices for the various
matches vectors. Also, the first two plots are of conditional probabilities, so their probabilities
may not sum up to one. However, the final plot is a PMF and the sum of its probabilities should
be one.)

4. Keno
Keno is similar to Lotto in that the players choose K numbers out a possible N and the
players are paid based on matching k numbers. However in Keno, the State draws n ≥ K
numbers. Such a game is referred to as an (N, n, K) Keno game. The probability of getting k
matches in an (N, n, K) Keno game is
n N −n
 
k K−k
P (k; N, n, K) = N
 ; k = 0, 1, . . . , K.
K

−n
where nk is the number of ways a player can match k desired numbers, N
 
K−k is the number of
N

ways a player can match K − k unwanted numbers, and K is the total number of ways that a
player can choose K numbers from a possible N numbers.

4.1. Assignment
In a hypothetical scenario, consider playing a (60, 20, 10) Keno game. What is the proba-
bility of matching 0 ≤ k ≤ 10 numbers?

(Optional) Write Matlab functions named keno game.m and keno histo.m that provide
the same information as lotto game.m and lotto histo.m, respectively. Use these pro-
grams to list and plot example plays and interesting graphs.

The Lotto program given earlier is a special case of the Keno program. How would you
use the Keno program to simulate the Lotto experiment?

5. Horse Racing
In a 12 horse race, there are 12! = 479001600 possible ways for the horses to finish, so
choosing the order of all 12 is a long shot. However, there are only (12)(11)(10) = (12)3 = 1320
ways for the order of finish for the first, second, and third horse to finish. Matching the top three
horses in order is known as a ‘trifecta.’

5.1. Assignment
(Optional) Write a Matlab program that simulates many horse races and keep track of
the number of trifecta’s that are hit. Have the program display (or echo) the estimated
probability of hitting a trifecta. What is the theoretical probability of hitting a trifecta?
How does the estimated probability compare to the actual probability. Use many trials.

A ‘trifecta box’ bet allows a player to pick the top three horses without specifying the
order. These bets cost 6 times as much a regular trifecta bet. Why? How many possible
ways can a trifecta box? (Hint: Think about going from permutations to combinations.)

(Optional) Write a Matlab program that simulates many horse races and keep track of the
number of trifecta boxes that are hit. Have the program display (or echo) the estimated
probability of hitting a trifecta box. What is the theoretical probability of hitting a trifecta

13
box? How does the estimated probability compare to the actual probability. Use many
trials.

14
Anexo 2. Probability, Conditional Probability and
Bayes’ Theorem in Matlab2
1. Introduction
In this lab you will use Matlab to help solve a variety of problems in probability theory. Last
exercises require familiarity with Bayes’ theorem.
You will use two of Matlab’s random-number functions, rand and randperm, to simulate
random experiments. These can be used to check your solutions to simple problems – for more
complex problems where it is difficult or impossible to find an analytic solution, these simulation-
based methods are often a good alternative.

2. Simple Simulation
Carrying out probability experiments is known as sampling. In probability theory it is useful
to distinguish between sampling with replacement and sampling without replacement. In the
former case, the conditions of a probability experiment remain the same from one experiment
to the next, so that the probabilities do not change. In the latter case, the conditions change,
based on the outcome of previous experiments. For example, consider selecting balls from a
bag containing 3 red balls and 3 green balls. If the balls are replaced after each experiment,
the probability of selecting a green or red ball will always be 0.5. However, if the balls are not
replaced, selecting a green ball on the first experiment will make selecting a green ball less likely
for the second experiment. Examples of sampling with replacement include tossing a coin or
throwing a die. Examples of sampling without replacement include lottery draws or selections
for a football team.
In Matlab, you can use the rand function to simulate sampling with replacement, and
randperm to simulate sampling without replacement.

2.1. Sampling with replacement


The rand(n,m) function generates an n×m matrix of random numbers, uniformly distributed
between 0 and 1. A vector of these numbers can be used to simulate repeated experiments, where
each possible outcome has a fixed probability. For example, consider an experiment where event
A occurs with probability 0.5, B occurs with probability 0.3 and C occurs with probability 0.2.
This experiment could be simulated as follows:

Set w = rand(1,1).

Then if w ≤ 0,5, say event A has occurred, if 0,5 ≤ w ≤ 0,8 then say B has occurred, and
otherwise say C has occurred.

If the experiment is repeated many times, the results can be used to estimate event proba-
bilities. The more experiments there are, the more accurate the estimation becomes. You will
investigate this for the simple example of rolling a four-sided die, where each number from 1 to
4 occurs with probability 0.25. You should:

1. Use w = rand(100,1) to generate a 100-dimensional random vector, simulating 100 throws


of the die.
2
Material based on the course Computational Foundations of Cognitive Science from the University of Edin-
burgh.

15
2. Say that a 1 has been thrown on the ith experiment if the w(i) is less than or equal to
0.25. Count how many times a 4 has been thrown from the 100 experiments – call it n.

3. Estimate the probability of throwing a 4 as p(4) = n/100.

4. How close is this estimate to the true value, 0.25? Repeat the steps above for 500, 1000,
5000 and 10000 experiments. What do you find?

If each experiment involved rolling 2 dice, you could simulate N experiments using rand(N,2),
with each row corresponding to one experiment.

2.2. Sampling without replacement


The randperm(m) function produces a random ordering of the numbers from 1 to m. Suppose
you wish to choose two balls from a bag containing three red balls and three green balls. A single
experiment can be simulated as follows:

bag = [ 1 1 1 2 2 2 ] % 1=red ball, 2=green ball


perm = randperm(6) % random ordering of the numbers 1 to 6
% simulating the order in which balls are drawn
draw = perm(1:2) % only consider the first two balls
balls = bag(draw) % find the actual two balls drawn, in order

You will repeat this simulation to estimate the probability of drawing a red ball first, then
a green ball second.

1. Write a Matlab program to repeat the above simulation 100 times. Produce a count, n, of
how many times that a red ball was drawn first, and a green ball second.

2. After repeating the simulation, estimate the probability using p(red, green) = n/100

3. Calculate the true probability on paper. How close is your estimate?

4. Repeat the above steps for 500, 1000, 5000 and 10000 experiments. What do you find?

3. Problems
On paper, calculate the solutions to the following problems. In each case, check your answer
by writing a Matlab program to simulate the problem and estimating the required probability
from a very large number of experiments, using the methods from Section 2. You will need to
decide whether the problem is equivalent to sampling with replacement or sampling without
replacement.

1. A fair coin is tossed four times. What is the probability of getting two heads and two tails
(in any order)?

2. A lottery has balls numbered from 1 to 10. Five balls are drawn, and the winner must
match all five balls (ordering doesn’t matter). What is the probability of winning?

3. Two four sided dice are thrown at the same time. This is repeated three times. What is
the probability that a double 4 is thrown at least once out of the three times?

4. A four-sided die is thrown 6 times. What is the probability of throwing two 4s consecuti-
vely? (This is much easier to simulate than to calculate by hand!)

16
4. Case: Lecture Attendance
The head of the Department is worried about poor lecture attendance among students. He
decides to commission a survey to investigate possible causes. In particular, he is interested
in whether the timing of lectures affects attendance, and whether it varies between males and
females. The Department counts attendance at two lectures for near-identical courses, one held
at 9h00, the other at 10h00, and, using the database of students registered for each course, finds
the following data:

9h00 lecture attendance 10h00 lecture attendance


Present Absent Present Absent
Males 9 15 Males 27 9
Females 12 4 Females 18 6

You can load the above data as two matrices, data1 and data2, from the file lab2.mat. You
should be able to answer the questions that follow by performing computations directly on these
matrices using vectorization techniques. We use M to denote the event that a student is male,
F for the event that a student is female; P for the event that a student is present, and A for
the event that a student is absent. Obviously these two pairs of events are mutually exclusive!

1. For each lecture, use the data to find matrices giving the joint probability tables of being
present or absent from a lecture and being male or female, i.e.,

Present Absent
Males p(M ∩ P ) p(M ∩ A)
Females p(F ∩ P ) p(F ∩ A)

2. For each lecture, find two vectors, one giving p(M ) and p(F ), the other giving p(P ) and
p(A).
3. Use your answers to the above two questions to state, for each lecture, whether a student’s
sex has is a factor affecting lecture attendance, by finding whether the events M and F
are independent of the events P and A.
4. Now compute the matrices giving the conditional probabilities of a student attending a
lecture, given the student’s sex, i.e.,

Present Absent
Males p(P |M ) p(A|M )
Females p(P |F ) p(A|F )

What conclusions would you give to the head of the Department?

5. Case: Tossing Biased Coins


This example requires you to compute probabilities from Binomial distribution. Suppose
there are two coins. One is a fair coin, with the probability of obtaining a head or a tail both
equal to 0.5. The second coin is biased: the probability of obtaining a head is 0.6 and the
probability of obtaining a tail is 0.4.

1. One of the two coins is selected (we don’t know which). The coin is flipped and comes up
heads. What is the probability that the coin chosen is the biased one, given that it came
up heads?

17
2. The same coin is flipped a second time. What is the probability that the coin comes
up heads, given that it came up heads on the first flip? Why are the two events not
independent?

3. Suppose one of the coins is flipped 2n times. Write a function in Matlab to compute the
probability of obtaining n heads and n tails, given that the coin is fair, and given that the
coin is biased (this should be an argument to the function). The function should work for
any value of n.

4. The coin has been randomly selected. Use your function to compute the probability that
the chosen coin is the biased one, given that n throws were heads and n throws were tails.
Plot the the value of this probability for n from 0 to 40. Explain the shape of your plot.

5. Now suppose that there are two biased coins (both the same as before) and one unbiased
coin. One coin is selected randomly. Given the same scenario of n heads and n tails being
obtained, modify your calculations from question 4 to calculate the probability that the
coin chosen is biased. What is the lowest value of n for which it is more likely that the
coin chosen was the unbiased one?

18
Anexo 3. Continuous Distributions and Language
Modelling3
1. Introduction
In this practical you will use the exponential distribution to model the firing pattern of a
neuron. This requires familiarity with the lecture material on continuous probability distribu-
tions. In addition, you will study the distribution of letters (alphabetic characters) in the English
language.

2. Confirming the model


Under certain laboratory conditions, a neuron is found to have a mean firing rate of 10Hz
— in other words, it fires on average once every 0.1 seconds.
We say that T is the random variable measuring gap between successive firing times. Data
on neuron firing times have been collected in the laboratory. You will use this data to check that
the exponential distribution is a good model for the random variable T .
Load the vector firingData from lab3a.mat. This contains 1000 recordings of gaps between
successive firing times, i.e., samples of T .

1. Write down the probability density function for T , assuming that it has an exponential
distribution.

2. Given that we know the mean firing rate to be 10Hz, what is the best choice of the
parameter, λ, of the exponential distribution model?

You can use a histogram to plot the probability density of the sample firing data. To produce
a histogram, use the following Matlab commands:

>> n=histc(firingData, 0:0.025:1);


>> bar(0:0.025:1, n/(1000*0.025),’histc’)

The first command divides the samples into ‘bins’, each with width 0.025, and produces a
count, n, of how many samples are in each bin. The second line calculates the probability of
each bin, by diving the count by the total number of samples (1000) and the width of the bin,
and then plots this as a bar chart.

1. Produce the probability histogram, as described above.

2. On the same plot, display the probability density function for the exponential distribution
with your parameter chosen in Question 2 (use Matlab’s fplot function). How well does
it fit the experimental data?

3. Using the model


Use your exponential model to compute:

1. p(T ≤ 0,15)

2. p(T > 0,1)


3
Material based on the course Computational Foundations of Cognitive Science from the University of Edin-
burgh.

19
3. p(T > 0,15|T > 0,05). This is the probability that the neuron waits more than 0.15s before
firing, given we have observed that it has already waited 0.05s.

4. Can you explain the connection between your last two answers?

4. Language modeling and entropy


Data on the occurrence of each letter have been obtained from the comprehensive English
dictionary found in the file /usr/share/dict/words (using only words containing entirely cha-
racters and no numerals), in Linux. You will use the data to create two probabilistic models.
Load the file lab3b.mat into Matlab. This creates the following variables:

chars, an array containing all the letters in order, and a 27th symbol, <b>, signifying the
gaps between words — this should be treated like any other character.

unigram counts, a vector containing the number of occurrences in the dictionary of each
letter. For example, unigram counts(1) is the number of times ‘a’ occurs in the dictionary.

bigram counts, a matrix containing counts of pairs of adjacent letters in the dictionary.
For example, bigram counts(1,2) is the number of times ‘a’ is followed by ‘b’ in the
dictionary.

4.1. Analysis
1. In Matlab, list the letters ordered by how frequently they occur in the dictionary of English.

2. What is the average length of a word in the dictionary?

3. Compute the probability of observing each letter (including word breaks), assuming suc-
cessive letters in a word are independent.

4. Calculate the entropy of the distribution. What is the expected number of bits per letter
needed to code an English word?

5. What assumptions have you made in question 4 that mean that your answer is unlikely to
be true in practice for coding English text?

4.2. Bigram models


Your probabilities in the previous section constitute a unigram language model. You will now
create a bigram language model. This makes the Markov assumption — that the probability of
a letter depends on the preceding letter, but, given the preceding letter, is independent of all
other letters.

1. Use the data in bigram counts to compute the full set of bigram probabilities for letters,
p(Li |Li−1 ), where Li is any letter and Li−1 is the preceding letter.

2. Use the original unigram model to compute the probability of observing the word ‘enjoy-
ment’, and of observing the fake word ‘eejmnnoty’. (It is helpful to work using logs).

3. Now use the bigram model to calculate the same probabilities. Comment on your findings.

20
Anexo 4. Poisson Regression4
1. Introduction
When dealing with two or more variables, the functional relation between the variables is
often of interest. For count data, one model that is frequently used is the Poisson regression model
and applications are found in most sciences: technology, medicine etc. The Poisson regression
model is also implemented in many packages for statistical analysis of data. In this computer
lab you will learn more about:
The Poisson regression model and how to estimate the model parameters.
Model selection, i.e., the number of explanatory variables to use.
Before to start the lab, read the theory and try to explain the difference between linear
regression and Poisson regression.

2. Road Accident Data


The Swedish Road Administration is the national authority that has the overall responsibility
for the entire road transport system. One main issue is road safetybility and continuous work to
improve road safety is performed. From their internet site http://www.trafikverket.se; it is
possible to obtain a number of different statistics about road accidents5 . We will in this exercise
use traffic accident data from years 1950–2010. The data is used to fit a Poisson regression
model to the number of people perished in traffic accidents. The estimated model is then used
to predict the expected number of perished year 2016.
Start by download statistics about the number of people killed in road accidents reported by
the police from the year 1950 to 2010. The data can be obtained from the mentioned website.
However, the data obtained this way are in the format of an Excel spreadsheet that include also
some description at the top. We modified this file to get it into more manageable format and
now it is in the file named ‘lab4 1950.xls’. Import the data to the Matlab workspace with the
command
data = xlsread(’lab4_1950.xls’);
The variable data now consists of 9 columns but we are only interested in columns {1, 2, 5,
6}, i.e., {year, number of people killed, number of cars, amount of sold petrol}. We store the
data in a structure array
traffic = struct(’year’,data(:,1),’killed’,data(:,2),’cars’,data(:,5),...
’petrol’,data(:,6));
Plot the number of people killed each year
plot(traffic.year, traffic.killed, ’o’)
Try also plotting the number of people killed vs. number of cars and the petrol consumption.
Do you see any connections?
From the plot it can be seen that the trend of increasing number of people killed is broken
around year 1965. And from year 1970 the number starts to decrease. Some natural questions
arises. Why did the number of people killed increase in years 1950-1965? What was the reason
for the brake of the increasing trend? (Hint: right-side driving (1967), front seat-belts in new
cars (1969), mandatory use of front seat-belts (1975)).
4
Material based on the course Probability, Statistics and Risk from the Chalmers-University of Gothenburg.
5
Another good source for all kinds of statistics about transport and communications is the Swedish Institute
For Transport and Communications Analysis, http://www.sika-institute.se/.

21
3. The Poisson Regression Model
Lets say we have a sequence of count data, ni , i = 1, . . . , k, for some event, i.e., the number
of perished in traffic accidents in a year. This count data is assumed to be observations from
random variables Ni ∈ Po (µi ), (called responses or dependent variables) with mean value µi =
µi (xi1 , . . . , xip ). The variables, xi1 , . . . , xip , are called explanatory variables6 and are assumed to
measure factors that influence the count data.
We restrict µi to be a log-linear function7 ,

µi = exp(β0 + β1 xi1 + . . . + βp xip )

And thus the probability that Ni = n is,


β0 +β1 xi1 +...+βp xip
e−µi (µi )n e−e (eβ0 +β1 xi1 +...+βp xip )n
P (Ni = n) = = , n = 0, 1, 2, . . .
n! n!

3.1. Estimating model parameters


To simplify the notation we introduce xi0 = 1 and can now write the previous equation as,
 
p
X
E[Ni ] = µi = exp  βj xij  ,
j=0

where Ni ∈ Po (µi ) for i = 1, . . . , k.


The likelihood function is calculated as,
k k
Y Y µni
L(β) = P (Ni = ni ) = i
e−µi
ni !
i=1 i=1

where µi = µi (βp~ ) is a function of βp~ = (β0 , . . . , βp ). The ML-estimates βp~∗ = (β0∗ , . . . , βp∗ ) are
the values of β that maximize the likelihood function L(β). Often it is easier to maximize the
log-likelihood function,
k
X k
X k
X
l(β) = − log(ni !) + ni log(µi ) − µi .
i=1 i=1 i=1

By setting the first order derivates of the log-likelihood equal to zero, we get a system of
(p + 1) non-linear equations in βj ,
k   k
∂l(β) X ∂µi ni X
= −1 = (ni − µi )xij = 0, j = 0, . . . , p.
∂βj ∂βj µi
i=1 i=1

Usually, the equation system must be solved with some numerical method, e.g., the Newton-
Raphson algorithm. This is also the method implemented in the function lab4 regress, which
was written for the purpose of this lab and can be found in the course Web page. Use the
command “type lab4 regres” to see the code.
Poisson regression model belongs to a class of models called generalized linear models. In a
generalized linear model (GLM), the mean of the response, µ, is modeled as a monotonic (non-
linear) transformation of a linear function of the explanatory variables, g(β0 + β1 x1 + β2 x2 , . . .).
The inverse of the transformation function g is called the canonical link function. In Poisson
6
Several other names exist in the literature: independent variables, regressor variables, predictor variables.
7
Sometimes the model incorporates an extra term ti : µi = ti exp(β0 + β1 xi1 + . . . + βp xip ).

22
regression this function is the log function, but in other GLM’s different link functions are used,
see “doc glmfit” for a list of supported link functions in the Matlab function glmfit8 . Also,
the response may take different distributions, such as the normal or the binomial distribution.
Below, we will use related function glmval with the logarithmic link function to make predictions
from the fitted model, see the code below.

4. Poisson Regression of Traffic Data


We will now try to fit the Poisson regression model to the traffic data of the number of
people killed in road accidents. Above, we could see that there was a break in the trend of
increasing number people killed around year 1965-1975, mainly because of the improvement in
car safety due to the use of safety belts. Because of this it seems reasonable to fit our model to
data starting from year 1975.

traffic = struct(’year’,data(26:end,1),’killed’,data(26:end,2),...
’cars’,data(26:end,5),’petrol’,data(26:end,6));

Question 1: Which are the explanatory variables? And which is the response?

Redraw the plot from above for the reduced data set

plot(traffic.year,traffic.killed,’o’)
figure(1), hold on

We start the analysis with one explanatory variable, traffic.year. Note usage of the pre-
diction routine for the generalized linear models glmval

X1 = [traffic.year-mean(traffic.year)];
n = traffic.killed;
beta1 = lab4_regress(X1,n,1e-6);
my_fit = glmval(beta1, X1,’log’);
plot(traffic.year, my_fit, ’b-’)

Question 2: What is your estimate of β? Convince yourself that this is the solution. You
can utilize the following code for this purpose:
X0=ones(size(X1));
X=[X0, X1];
mu=exp(X*beta1);
X’*(n-mu)
Does it appear to be the solution? Judging from the plot, is this model sufficient to describe
the number of people killed in traffic accidents?

Although this simple model seems to capture the overall trend, adding further explanatory
variables may improve the fit. Thus, we try adding the number of cars as a variable in our model.

X2 = [traffic.year-mean(traffic.year), traffic.cars-mean(traffic.cars)];
beta2 = lab4_regress(X2,n,1e-6);
my_fit = glmval(beta2, X2,’log’);
plot(traffic.year, my_fit, ’g-’)
8
glmfit uses a method called weighted least squares to compute the β estimates.

23
Question 3: Have your estimates β0∗ and β1∗ changed? Does accounting for the number of
cars improve the fit?

It seems reasonable also to add the quantity of sold petrol as this would reflect the total
mileage of all cars9

X3 = [traffic.year-mean(traffic.year), traffic.cars-mean(traffic.cars),...
traffic.petrol-mean(traffic.petrol)];
beta3 = lab4_regress(X3,n,1e-6);
my_fit = glmval(beta3, X3,’log’);
plot(traffic.year, my_fit, ’r-’)

Question 4: Have your estimates of β changed now? Use the command format long to
display more digits. Which model do you choose?

4.1. Model selection – Deviance


It is not always easy to decide, just by looking at the plot, which model to choose. Even
though adding more variables improves the fit, it also increases the uncertainty of the estimates.
One method to choose complexity of the model is to use the deviance and a hypothesis test.
Let βp~∗ = {β0∗ , β1∗ , . . . , βp∗ } be the ML-estimates of the model parameters {β0 , β1 , . . . , βp } of
the full model with p explanatory variables and βq~∗ the estimates of a simpler model where only
q (q < p) of the explanatory variables have been used. Then for large k, and under suitable
regularity conditions, the deviance

DEV = 2 × (l(βp~∗ ) − l((βq~∗ )))

is approximately χ2 (p − q) distributed if the less complex model is true. Thus, it is possible to


test if the simpler model can be rejected compared to the full model.

Question 5: Use chi2inv to get the quantiles of the χ2 distribution. Consider 5 % signifi-
cance level for your test.

The deviance for model 3 compared to model 2 is calculated as

DEV2 = 2*traffic.killed’*([X0,X3]*beta3-[X0,X2]*beta2)

Question 6: Is the improvement with model 3 significant compared to model 2? Repeat the
test for model 2 against model 1 and also model 3 against model 1? Which model do you
choose? Do you think that there was a sufficient number of explanatory variables used to
explain the traffic deaths? Why?.

5. Prediction
Now we want to use our model to predict the expected number of perished in traffic accidents
six years from now, i.e., year 2016. In order to do this we first must have an estimate of the
number of cars that year. Start by plotting the number of cars vs. year,

figure(2)
plot(traffic.year, traffic.cars, ’o’)
hold on
9
Assuming that the mean fuel consumption of a car has been constant over the years – a 1970 year model of a
Volvo used about 10l per 100km which is approximately the same as for the 2000 year model. Of course, the year
2000 model has more than twice the horsepower.

24
We will here use a simple linear model for the number of cars, yi , year xi

yi = β0 + β1 xi + i

where the errors, i ∈ N (0, (σ )2 ), are assumed to be independent and identically distributed.
This is called a linear regression model. It is possible to estimate the parameters with the ma-
ximum likelihood method similar as for the Poisson regression model above.

Question 7: What is the likelihood function? Write it down.

In Matlab, the function regress computes the least-squares (LS) estimates of the linear re-
gression model. In the case of i being normally distributed, the LS method is equivalent to the
ML method with exactly the same estimates.

phat = regress(traffic.cars,[ones(length(traffic.cars),1) [1975:2005]’])


plot(1975:2016, phat(1)+phat(2)*[1975:2016],’r’)
cars_2016=phat(1)+phat(2)*2016;

Evaluate the fit by looking at the residuals.

res = traffic.cars-(phat(1)+phat(2)*traffic.year);
figure(3), plot(traffic.year,res,’o’)
figure(4), normplot(res)

Question 8: Do the residuals conform to the requirements of the model errors i ?

Using the following code provide with prediction of petrol consumption for 2016.

phat = regress(traffic.petrol,[X0 [1975:2010]’ ([1975:2010].^2)’])


plot(1975:2016, phat(1)+phat(2)*[1975:2016]+phat(3)*([1975:2016].^2),’r’)
petrol_2016=phat(1)+phat(2)*2016+phat(3)*2016^2;

Notice that this time quadratic model had to be fit to the data.

Question 9: Are you satisfied with the obtained fits for the petrol and the number of cars?

However, for our purpose these rough estimates are sufficient. The expected number of pe-
rished can now be predicted using µi = exp(β0 + β1 xi1 + . . . + βp xip ),

x=[1 2016-mean(traffic.year) cars_2016-mean(traffic.cars) ...


petrol_2016-mean(traffic.petrol)]’
my_2016=exp(beta3’*x) %----- Model 3 -----

Question 10: Is the prediction reasonable? Comment.

25
Anexo 5. Simulating a Binary Communication
Channel10
1. Introduction
A binary symmetric channel is a common communications channel model used in coding
theory and information theory. In this model, a transmitter wishes to send a bit (a zero or a
one), and the receiver receives a bit. It is assumed that the bit is usually transmitted correctly,
but that it will be “flipped” with a small probability (the crossover probability). This channel is
used frequently in information theory because it is one of the simplest channels to analyze.

2. Analyzing a Noisy Communication Channel


In this lab, our goal is to simulate the noisy channel discussed above. To generate random
zeros and ones, we must first create a Matlab function make Bernoulli matrix(m,n,p) that
generates a matrix m × n of zeros and ones, where the probability of being 1 for each element
of the matrix is equal to p.
That function will be used with with parameters n = 1 and p = 0,5. The parameter m defines
the number of transmitted digits. Then, we modulate the transmitted bits in the following way:
if a 0 is sent, we modulate it as −1, and if 1 is sent, we modulate it as +1. Next, we multiply
the modulated digits by µ. At this point, we generate an independent sample from a standard
normal distribution, multiply it by σ, and then add it to the modulated digit (±µ). Note that
for each modulated digit, we generate a different sample from the normal distribution.

Figura 1: A simple model for a binary communication channel.

The result is the noisy output Y = ±µ + N . To decode the transmission, we say a 0 was
transmitted if Y ≤ 0, and a 1 is transmitted if Y > 0. The overall proposed system is shown in
figure 1.

2.1. Assignment
Derive a formula for P (E). Then from your simulations of Y , experimentally estimate the
P (E). You do this by incrementing an error counter whenever Y ≤ 0 for a transmitted 1 and
Y > 0 for a transmitted 0. Divide the number of errors by the number of transmissions.
Estimate P (E) for µ = 5, m = 1000, and σ = 50, 25, 5, 2.5, 0.5, 0.25 and 0.05. Overplot the
2
estimated P (E) and the exact P (E) vs. SN R = 10 log10 ( σµ2 ). What do you conclude from this
plot?

10
Material based on the course Introduction to Communications Principles from Colorado State University

26
Anexo 6. System Reliability11
1. Introduction
The reliability of an engineering system12 is often defined as the probability that the system
will function as intended. We will also refer to the opposite concept, namely the failure probability
Pf (f stands for failure), which is the probability that the system will not function as intended.
The level of performance of a system will obviously depend on the properties of the system.
Assume that all interesting properties of an engineering system are described by a set of
parameters x1 , x2 , . . . , xn . We want the system to endure a set of loads of our choice13 (the
system might be subjected to more than one load). The magnitudes of these loads — let us
denote them y1 , y2 , . . . , ym — must however be limited, due to engineering imperfection, cost
limits, time limits, and the like: we understand that there are combinations of y1 , y2 , . . . , ym and
x1 , x2 , . . . , xn where the system capacity is exceeded and where the system will inevitably break
down. We formalize this by
The system functions as intended ⇔ h(y1 ; . . . ; ym ; x1 ; . . . ; xn ) > 0
The system does not function as intended ⇔ h(y1 ; . . . ; ym ; x1 ; . . . ; xn ) < 0

The function h is called the failure function (performance function, state function). If the
parameters and the applied “loads” are marred by randomness, we instead treat them as ran-
dom variables Y1 , Y2 , . . . , Ym and X1 , X2 , . . . , Xn . In terms hereof, we can now write the failure
probability Pf as
Pf = P (h(Y1 ; . . . ; Ym ; X1 ; . . . ; Xn ) < 0)
The random variable Z = h(Y1 ; . . . ; Ym ; X1 ; . . . ; Xn ) is sometimes referred to as the safety
margin.
In this computer exercise, our goal is to calculate Pf . The function h will always be given, as
will the distribution functions of Y1 , . . . , Ym and X1 , . . . , Xn . We will obtain Pf from simulations.
No real-world data today!

Figura 2: A typical MOSFET connection.

2. MOSFET
A depletion-mode MOSFET (Metal-Oxide-Semiconductor Field-Effect Transistor) is a three-
terminal electronic device. When an n-channel MOSFET is connected like in figure 2, then it
11
Material based on the course Probability, Statistics and Risk from the Chalmers-University of Gothenburg.
12
e.g., a construction, a vehicle, a production line, a multi-article stock-room logistic system, a computer
network, a nuclear power-plant, a dam, a communication satellite, or a finance portfolio.
13
e.g., the construction must bear a certain amount of wind load or weight; the vehicle must cover a satisfactory
distance before its engine starts malfunctioning; the production line must produce goods continuously for at least
a week (say) to be profitable; the stock-room logistic system must deliver at least 99 % (say) of the goods on order
on time and to the right orderer; etc.

27
has the following voltage-current characteristic

2
A × VT R ,
 U > VT R (constant current region)
2
I = A(2VT R U − U ), 0 < U < VT R (triode region)

undefined, U <0

Here U is the applied voltage (i.e., the drain-source voltage), VT R is a threshold voltage
(always positive for n-channel MOSFETs), and A is the conductance parameter.
When current flows into the positive terminal of a passive device, electrical power is dissipated
in the device as heat. This electrical power P is equal to the product of the port voltage and
port current. For a multiport device, the total electrical power input is given by the sum of input
power taken over all ports. The dissipated energy will increase the temperature of the device,
which affects the properties of it. Every device has a maximum allowable operating temperature
limit that must not be exceeded. In other words, there is a maximum electrical power limit Pmax .
In our case,
U × I < Pmax
if the MOSFET is to work well. Assume that U , VT R , and A are independent random variables:

U — Normal with mean 10 V and standard deviation 2 V.


A — Log-normal with median 1 mA/V2 and σ = 0,2.
VT R — Uniform between 3 V and 5 V.

and that Pmax = 300 mW.

Pmax = 300e-3;
N = 20000;
EU = 10;
DU = 2;
medianA = 1e-3;
sigma = 0.2;
aVTR = 3;
bVTR = 5;
U = EU + DU*randn(1,N);
A = medianA*exp(sigma*randn(1,N));
VTR = aVTR + (bVTR-aVTR)*rand(1,N);
I = zeros(1,N);
index1 = find(U >= VTR);
index2 = find(U < VTR);
I(index1) = A(index1).*VTR(index1).^2; % Constant current region
I(index2) = A(index2).*(2*VTR(index2).*U(index2)-U(index2).^2); % Triode region
h = Pmax-U.*I;
Pfhat = sum(h<0)/N

2.1. Assignment
Report simulated probabilities of failure (do few repetitions).

Is P (U < 0) negligible? If U < 0 was not negligible, it is bad for the MOSFET, so let us
consider this case to be a failure. Write down a failure function h(Pmax ; U ; A; VT R ) with
this extra condition.

28

Potrebbero piacerti anche