Using approximation to find a value of theta

97 Views Asked by At

So I have one vector of alpha, one vector of beta, and I am trying to find a theta for when the sum of all the estimates (for alpha's i to n and beta's i to n) equals 60.

Basically what I did is start from theta = 0.0001, and iterate through, calculating all these sums, and when it is lower than 60, continue by adding 0.0001 each time, while above 60 means we found the theta.

I found the value theta this way. Problem is, it took me about 60 seconds using Python, to find a theta of 0.456.

What is quicker approach to find this theta (since I would like to apply this for other data)?

2

There are 2 best solutions below

0
On

Define

$$f(\theta)=\sum_{i=1}^{N}\frac{e^{\alpha_i(\theta-\beta_i)}}{1+e^{\alpha_i(\theta-\beta_i)}}-60$$

You want to find a $\theta$ for which $f(\theta)=0$. This is a common task, and is called root finding. There are numerous ways to achieve that, and python (scipy) has a built in function that does that - fsolve.

0
On

I used the bisectional method for finding the root.