Probability help r studio

I am having a little trouble working out how to calculate a few things in R studio

How would I go about calculating the probability of an event occurring successfully a set number of times but then not occurring? For example, if the sample size was 20 and the probability like 0.4 how could I calculate the probability that only the first X number are successful and the rest are failures. This does refer to binomial cases where the result is like Head/Tails or Pass/fail on test.

Another thing I am struggling with is how to calculate the 25th, 75th percentiles and interquartile range when given mean and standard deviation.

The final thing I'm trying to work out is how to combine the probabilities of two events. For example, how do I combine the probability of say the first 3 events of the sample being successful with the probability of 3 events being successful out of the remaining 10.

Another case of combining which I am struggling with is calculating the probability of a certain number of random samples being within a range. I can calculate the probability of a single sample being within the range but unsure how to take that and combine to say find out the probability that 4 out of 15 are within that range.

Would love any help I can get.

I do need to be able to create an R code to generate my solution unfortunately which is why I am getting confused with some parts. I did try to create a post to separate the issues but because I am new they will not let me post more than one time a day.

For my second question, I have been given a mean and standard deviation value which I am meant to somehow use R to generate the 25th and 75 percentiles and find the interquartile range. This data is different to the binomial data from my first question.

My last question may be more of a theoretical one but it has been hard to find the accurate information to get my head around what to do so that I can work out what R code to generate to get my answer. I know or am learning how to get the probability for the individual events but the probability I must calculate is based on two events. For example, the probability of getting heads for the first five times then getting heads a further 2 times within the sample.

For the question where I am given the mean and standard deviation of weight, I can calculate the probability of someone being within that weight. I need to then calculate the probability that says 3 out of 10 people from a random selection are within a defined weight category.

I suspect there might be some general rule which applies when trying to work out the probability of something occurring with those extra conditions but I am having trouble understanding exactly what the formula or rules are. I can only find very basic examples or something that is far too complicated to understand.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.