Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 3 years ago.
Improve this question
Given the equation (depth = log(c * p + 1) / log(c * 1000 + 1) * p)
How can I find p?
I wanted to get an equation with p = sqrt(exp(... or something like this
The isn't an analytical solution to problems like this because they contain the variable both inside and outside a transcendental function like log().
With some quick algebra, you can simplify the expression to
p*log(1 + c*p) = b
where b=depth*log(1+1000*c) is a constant.
I propose using a single point iteration, to get a numeric result.
Start with some guess of p=1 or something and then do a loop until you converge to a value of (c# shown below).
b = depth*log(1+1000*c);
p = 1;
do
{
p_old = p;
p = b/log(1+c*p);
}
while( abs(p-p_old)> 1e-6);
and hope it converges soon.
Related
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)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
How do we go about numerically solving equations of the sort below using R?
Please note, this can be shown to be convex and there is a separate thread on this.
https://stats.stackexchange.com/questions/158042/convexity-of-function-of-pdf-and-cdf-of-standard-normal-random-variable
This question has been posted on the Mathematics Forum to get Closed Form or other Theoretical Approaches, but it seems numerically solutions are the way to go?
https://math.stackexchange.com/questions/2689251/solving-equations-with-standard-normal-cdf-and-pdf-optimization
You can use the build in optimize function to directly optimize the original function:
g <- function(x, xi) {
(xi * x + dnorm(xi * x) / pnorm(xi * x))
}
fun <- function(x, xi, K) {
K * g(x, xi) + (K - x) * g((K - x), xi)
}
optimize(fun, interval = c(0, 10), xi = 1, K = 1)
#> $minimum
#> [1] 1.173975
#>
#> $objective
#> [1] 1.273246
Your original problem f(x) = g(x) can be formulated as a root finding problem f(x) - g(x) = 0. You can then use the uniroot function to solve that. See ?uniroot for details.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I want to know how to solve a recurrence relation in 2 variables. I want to solve below relation:
F(n,m) = F(n-1,m) + F(n,m-1) + 1
Initial conditions:
F(m,0) = m
F(0,n) = n
F(0,0) = 0
F(n,m)
{
if (n==0)&&(m==0)
return 0
else if (n==0)
return m
else if (m==0)
return n
else
return F(n-1,m) + F(n,m-1) + 1
}
Only parameters (≦ n, ≦ m) occur, one may exclude n or m being 0, so if you could hold a table of n×m that would be the optimal complexity: O(n . m).
One sees, that F(n - 1, m - 1) are both called, from F(n - 1, m) and F(n, m - 1), so a naive solution has a higher complexity.
Not wanting to spoil the joy of finding an algorithm, only some hints:
F(n, m) = F(m, n) so you may use n ≦ m.
(table, result) = F'(table, n, m) caching of results in recursive function
I personally sometimes like to start with an iterative non-functional procedure to fill a table, starting from 0 upwards. And then turn that into functional notation. For complexity an iterative procedure would already suffice.
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 10 years ago.
Improve this question
Is there a way to solve a general recurrence relation of the form
a(n)=a(n-1) * a(n-2)....
I mean I can use the matrix method to solve a relation of the form
F(n)=a1*F(n-1) + a2*F(n-2).......+ ak*F(n-k)
but what to do when there is a '*' sign instead of '+'
Use logarithms:
a(n) = a(n-1) * a(n-2) * a(n-3) * ....
Take log of both sides:
log(a(n)) = log(a(n-1) * a(n-2) * a(n-3) * ...)
Use the fact that log(a * b) = log(a) + log(b) to split up the factors:
log(a(n)) = log(a(n-1)) + log(a(n-2)) + log(a(n-3)) + ...
Now, if you just say that F(n) = log(a(n)) then this equation looks just like your second equation. Use the matrix method to solve for log(a(n)):
log(a(n)) = X
Which leaves:
a(n) = e ^ X
(Assuming you take natural logarithms)
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.