繁体   English   中英

如何在R中的expoetial方程中获得x的值

[英]How to get the value of x in an expoetial equation in R

我有以下等式,我想得到 x 的值。

 (1/(1+exp(-(0.1348*x + 64.7027))))+ (x-70)=0

我尝试了 library(nleqslv),但没有成功获得 x

定义一个函数f

f <- function(x) 1/(1+exp(-(0.1348*x + 64.7027))) + (x - 70)

为了查看根可能落在何处,绘制函数,尝试几个限制。

curve(f, from = 0, to = 100)

上面那个有相反符号的端点,所以这是uniroot的工作。

uniroot(f, interval = c(0, 100))
#$root
#[1] 69
#
#$f.root
#[1] 0
#
#$iter
#[1] 1
#
#$init.it
#[1] NA
#
#$estim.prec
#[1] 69

为了获得根的值,请尝试以下两种方法中的任何一种。

uniroot(f, interval = c(0, 100))$root
#[1] 69

y <- uniroot(f, interval = c(0, 100))
y$root
#[1] 69

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM