Normal Distribution in R. Finding P [closed] - r

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm having trouble solving a normal distribution problem in R. I'm unfamiliar with the syntax and would like some help.
If X~N(2,9), compute
a. P(X>=2)
b. P(1<=X<7)
c. P(-2.5<=X<-1)
d. P(-3<=X-2<3)

You are looking for the pnorm function. This is the normal CDF. So you want to do something like:
# A
1 - pnorm(2, mean = 2, sd = 9) # = 0.5
# B
pnorm(7, mean = 2, sd = 9) - pnorm(1, mean = 2, sd = 9) # = 0.255
I think you can figure out the last two yourself.

Related

How to solve nonlinear equations in R [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
For example, I try to solve for x: 12*exp(-2x/4)=0.5, or x^2+3x^4+9x^5=10, is there any method in R to solve such equations?
Try with uniroot function
r1 <- uniroot(function(x) 12*exp(-x/2) - 0.5, c(-1000, 1000))
r2 <- uniroot(function(x) x^2 + 3*x^4 + 9*x^5 - 10, c(-1000, 1000))
r1$root
[1] 6.356108
r2$root
[1] 0.943561
You have to define:
a function of the type f(x) = 0 (and remove the second member of equality)
an interval within which to search for the solution

elegant way to write a function [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
What is a more elegant way to write the below function. I am trying to practice my function development skills, and I am simply trying to manually recreate the CIs of a linear model. I am very well aware of the confint(model) function, but still...
jad<-function(x, y) {
model<-lm(y~x)
std.err<-coef(summary(model))[, 2]
coef.model1<-coef(summary(model))[, 1]
upper.ci<-coef.model1+1.96*std.err
lower.ci<-coef.model1-1.96*std.err
print(upper.ci)
print(lower.ci)
}
What about the code below?
jad <- function(x, y) {
`colnames<-`(
coef(summary(lm(y ~ x)))[,1:2] %*% matrix(c(1, 1.96, 1, -1.96), nrow = 2),
c("upper.ci", "lower.ci")
)
}

Pls convert this R code of bit error probability into matlab [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
solution of the bit error probability problem
prob=function(E,m) #--- prob is the estimated error probabity for given values of signal to
#---noise ratio E and sample size m
{
stopifnot(E>=0 & m>0) #--- this says that the function won't accept negative values of E and
#---m shoulde be at least 1
n=rnorm(m) #--- this says that n is a random sample of size m from N(0,1)
#---distribution
m=mean(n< -sqrt(E)) #--- this says that m is the proportion of values in n which are less
#---than the negative root of E
return(m) #--- this gives us the value of m, which is the estimated error
#---probability
}
E=seq(0,2,by=0.001)
sam=1000
y=sapply(E,prob,m=sam)
p=10*log10(E)
plot(p, log(y),
main="Graph For The Error Probabilities",
xlab=expression(10*log[10](E)),
ylab="log(Error Probability)",
type="l")
You can try the MATLAB code like below
clc;
clear;
close all;
function y = prob(E,m)
assert(E>=0 & m>0);
n = randn(1,m);
y = mean(n+sqrt(E)<0);
end
E = 0:0.001:2;
sam = 1000;
y = arrayfun(#(x) prob(x,sam),E);
p = 10*log10(E);
plot(p,log(y));
title("Graph For The Error Probabilities");
xlabel('10\log_{10}(E)');
ylabel("log(Error Probability)");
OUTPUT (MATLAB)
OUTPUT (R)

Solving Vector Multiplication (general problem) [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I am trying to solve a Mathematical equation in one of my geometric modelling problem.
Let's say if I have 2 vectors, A and B, and I have the following equation:
A x B = c (c is a scalar value).
If I know the coordinate of my vector B (7/2, 15/2); and I know the value of c, which is -4.
How can I calculate my vector A, to satisfy that equation (A X B = c) ?
The problem is underdetermined; there isn't a unique such A. I assume that by "multiplication" you mean the cross product.
A = (x,y)
B = (7/2, 15/2)
A×B = x(15/2) - y(7/2)
-4 = (15x-7y)/2
15x - 7y = -8
This gives a line along which points A=(x,y) can lie. Specifically, for any real number t,
x = -1 + 7t
y = -1 + 15t
gives a solution.

how to solve IVP using separable variable [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
the question is:
x dy/dx = 2y ; y(0)=0
because when i solve this problem the integration constant 'c' gets zero... and i have to find its value in order to calculate a solution to given IVP
Unless I'm mistaken, this question gives c = 0 for y(0) = 0
x*dy/dx = 2y
x*dy = 2y*dx
dy / 2y = dx / x
ln(2y) = ln(x) + c
e^(ln(2y)) = e^(ln(x) + c) = e^ln(x)*e(c)
2y = x + c
solving for y(0) = 0 gives c = 0, as you stated.
Why do you think c must not be 0?

Resources