Conditional probability: independence?

Consider the following problem:

A prepared student answers correctly to each oral question independently from one another with probability $ 0.95$ . If, however, he is not prepared, he answers correctly with probability $ 0.1$ . $ 80$ % of the students taking the exam are prepared. Donald answers wrong to the first question. What is the probability he is prepared? Donald asks his teacher if he can have a second question. Determine the probability that he will answer correctly.

So, as far as the first question is concerned, we easily compute:$ $ P(P|W_1)=\frac{P(P)\cdot P(W_1|P)}{P(P)\cdot P(W_1|P)+P(P^c)\cdot P(W_1|P^c)}=\frac{0.8\cdot 0.05}{0.8\cdot 0.05+0.2\cdot 0.9}$ $ according to Bayes’s theorem. I’m actually concerned with the second question. I approached it making the following thought: since we are given that each student answers each question independently of one another, it shouldn’t matter whether Donald answered wrong or right to the first question in oder to answer correctly to the second question (I’m assuming from the text that $ P(R_2|W_1)=P(R_2)$ ). Thus I computed:$ $ P(R_2)=P(P)\cdot P(R_2|P)+P(P^c)\cdot P(R_2|P^c)=0.8\cdot 0.95+0.2\cdot 0.1$ $ which is $ 0.78$ . According to my teacher, right answer is:$ $ P(R_2|W_1)=\frac{P(W_1R_2|P)\cdot P(P)+P(W_1R_2|P^c)\cdot P(P^c)}{P(W_1)}$ $ $ P(W_1)$ is computed as before in the previous equation. Whereas the numerator is:$ $ P(W_1|P)\cdot P(R_2|P)\cdot P(P)+P(W_1|P^c)\cdot P(R_2|P^c)\cdot P(P^c)$ $ this gives $ 0.25$ as overall result, which is way lower than mine. He’s assuming that each $ R_i$ , $ W_i$ is idependent from each other knowing that either event $ P$ or $ P^c$ occured. Thus he’s assuming, if I’m not mistaken, conditional independence. So, what is the correct way to solve this problem? Which is the best appraoch? What will you assume reading that text? I would probably stick with my solution, since it’s weird that one answers independently of each question only if he’s either prepared or not.

Excel Conditional Formating From Adjacent Cells

Basically I am trying to have my columns mimic font and background colors of one entry cell. The sheet is only 6 columns wide.

ie;

A22=date, B22=user input/auto populate, C22=user input (drop down), D22=user input/auto populate, E22=user input/auto populate, F22=user input …

So when an item is selected from the cell in the C column how would cells in columns a,b,d,e,and f mimic the font and background color formatting that has been set by my superiors?

Here is a link of a screenshot

Ux of conditional logic when numbered questions

I would like to apply conditional logic to a questionnaire to make it slimmer and easier to complete for our users. The new questions will appear dynamically appear on the page, under the trigger questions. Ex: How many employees work for the company apart from the founders? (if 0, question is not displayed if > 0, question will dynamically appear)

However, the questions need to be numbered: 1. How many employees work for the company apart from the founders?

How will I deal with the appearance of the numbers? Because until when the question appears (if it does), users will see skipped numbers and I believe that’s not good, but I wouldn’t know how to do otherwise. It will appear like this: 1. How many employees work for the company apart from the founders? 3. Where is the company based

Do you have any suggestions? Thanks!

Conditional Expectation from a joint pdf


Suppose that both $ X$ and $ Y$ have joint pdf $ f(x,y)$ and $ Y$ has mariginal density $ f(y)=\int_{\mathbb R}f(x,y)dx$ . The conditional density of $ X$ given $ Y$ is given by $ f(x|y)=\dfrac{f(x,y)}{f(y)}$ and $ E(X|Y=y)=\int_{\mathbb R}xf(x|y)dx$ . Let $ \sigma(Y)$ be the sigma field generated by $ Y$ and show that $ E(X|\sigma(Y))=\theta(Y)$ where $ \theta(y)=E(X|Y=y)$

My question here is what is $ \theta(Y)$ ? Is it $ E(X|Y=Y)$ and if so what does this mean?

I know I need to show that $ $ \int_AE(X|\sigma(Y)dP=\int_A\theta(Y)dP \;\;\; \forall\; A\in\sigma(Y) $ $ but im unsure how to start since im unclear on what $ \theta(Y)$ means.

String conditional formatting depending on its length

I just applied to a job interview and they asked me to do something like this:

We are given a string Str representing a number, which we would like to reformat. String Str consists of N characters: digits, spaces and/or dashes. It contains at least two digits.

Spaces and dashes in string Str can be ignored. We want to reformat the given number in such a way that the digits are grouped in blocks of length three separated by single dashes. If necessary, the final block or the last two blocks can be of length two.

For example, given string Str=”00-22 58 5555 9361″, we would like to format it as “002-258-555-593-61”.

Write a function that, given a string Str representing a number, returns the reformatted string above.

For example:

  • Given Str=” 123 456—789″ should return “123-456-789”.
  • Given Str=”1 – 23 4567-890″ should return “123-456-78-90”.

Assume that:

  • N is a integer within the range [2-100];
  • string Str consists only of digits (0-9), spaces and/or dashes(-);
  • string Str contains at least two digits.

Focus on correctness, the performance will be not evaluated.

My answer was:

    internal string Solution(string Str)     {         // Empty string is not a valid input         if (Str.Trim().Length == 0) throw new ArgumentOutOfRangeException("Empty string is not a valid input");          // Get digits         var digitsOnly = new string(Str.Where(c => char.IsDigit(c)).ToArray());          // Not enough digits in string         if (digitsOnly.Length < 2) throw new ArgumentOutOfRangeException("Not enough digits in string");           //Select formatting type         if (digitsOnly.Length % 3 == 0)         {              //Total lenght is divisible by 3 use {###-...-###} formatting              // Only 3 digits return             if (digitsOnly.Length == 3) return digitsOnly;              var threeDigitsList = Enumerable             .Range(0, digitsOnly.Length / 3)             .Select(i => digitsOnly.Substring(i * 3, 3))             .ToList();              return string.Join("-", threeDigitsList);          }         else if ((digitsOnly.Length - 4) % 3 == 0)         {             //Total lenght -4 is divisible by 3 use {###-...-##-##} formatting              // Only 4 digits format and return             if (digitsOnly.Length == 4) return digitsOnly.Substring(digitsOnly.Length - 4, 2) + "-" + digitsOnly.Substring(digitsOnly.Length - 2, 2);               var threeDigitsList = Enumerable             .Range(0, (digitsOnly.Length - 4) / 3)             .Select(i => digitsOnly.Substring(i * 3, 3))             .ToList();              return string.Join("-", threeDigitsList)                                 + "-"                                 + digitsOnly.Substring(digitsOnly.Length - 4, 2)                                 + "-"                                 + digitsOnly.Substring(digitsOnly.Length - 2, 2);           }         else if ((digitsOnly.Length - 2) % 3 == 0)         {              //Total lenght -2 is divisible by 3 use {###-...-##} formatting              // Only 2 digits return             if (digitsOnly.Length == 2) return digitsOnly;              var threeDigitsList = Enumerable             .Range(0, (digitsOnly.Length - 2) / 3)             .Select(i => digitsOnly.Substring(i * 3, 3))             .ToList();              return string.Join("-", threeDigitsList)                                 + "-"                                 + digitsOnly.Substring(digitsOnly.Length - 2, 2);          }          return Str;     } 

I know there is a lot of room for improvement but I can’t figure how.

Which improvements would you do to make it better in terms of readability, maintainability and edge case testing?

PowerApps Conditional formatting

Looking for advice on how to implement a conditional formatting based on several factors. I’m still working on my Raw Materials Inspection app:

n

We have 2 factors to consider: Probation and Time.

If a supplier is “On Probation” their parts should be Inspected every time and the result in the purple box would be YES.

The second factor is time. A part may need to be inspected every XX days (the Frequency of Inspection). If the Last Inspected date + Frequency-in-Days is <=Today() then the part is due for inspection and the result would be YES in the green box above.

I had both of these scenarios covered in the following text formula (note: INSP-NOW represents the Probation status):

If((Today() >= DateAdd(ThisItem.'LAST-INSP',Value(ThisItem.'FREQ-IN-DAYS')))," INSPECTION DUE ", (ThisItem.'INSP-NOW'.Value="YES")," INSPECTION DUE "," ") 

Now someone has introduced the proverbial monkey wrench into my conditional statement — If the Frequency is set to zero, then the time test should be ignored (that is, if FREQ =0, only check if the supplier in on Probation).

PowerApps IF statement uses a format of

IF(test1,result1, [test2, result2,...,] default)

so do the logical test stop once a true is encountered — that is, if test1 is true does the If statement ever process test2?

Do I use the Switch statement here instead?

Thanks,

gpence

Conditional Formatting across a range of cells with a formula in Google Sheets

I have a calendar put into Google Sheets with the data put in as dates such as “9/24/2018”.

I have a separate sheet with a data set that has rows that classes end such as “9/24/2018”.

I want to conditionally format the entire calendar so that if any cell in the calendar has a date that matches one in the data set it will format.

I’m using this formula so far, but no dice. Not sure what I’m doing wrong.

COUNTIF(indirect("Training Classes!$  E:$  E"),A1)>1 

The calendar range is B6:X37 just in case that matters.

For the record, the formula does work if I assign it to a specific cell and put it in a cell.

So if I put somewhere =COUNTIF(indirect("Training Classes!$ E:$ E"),S27)>1) then it is true. Its just the conditional that’s having issues.

Apache mod proxy load balancer fail over conditional

I have a configuration similar to this one:

<VirtualHost *:80>  <Proxy balancer://X_Balancer>   BalancerMember http://server1.sth/   BalancerMember http://server2.sth/   BalancerMember http://server3.sth/   BalancerMember http://server4.sth/   BalancerMember http://server5.sth/   BalancerMember http://server6.sth/   BalancerMember http://server7.sth/   BalancerMember http://anotherApacheLB.sth/ lbset=1  </Proxy> ProxyPass balancer://X_Balancer/ ProxyPassReverse balancer://X_Balancer/ 

the server anotherApacheLB.sth contains another set of servers being balanced also, the same way this one is.

with this configuration, anotherApacheLB.sth will only get traffic if all members are “down”. If I end up with just 1 instance up, that instance will be hammered hard, and that will impact processing.

I wanted to configure this in a way that: if 3 servers from set 0 are down, add anotherApacheLB.sth to the rotation.

Thanks.

How to use Sheet and Range protection and Conditional formatting simultaneously in Google Sheet?

Here I gave conditional formatting in the column E , with two colors for the users A and B respectively. Now I want to enable access to A and B for their respective cells in columns F and G. I can do it manually. But I want to do the same for future rows of data, which automatically copies the cell protection rules to columns F and G in respect to the user in the column E. How to do it ?

Sample Google Sheet