R语言小例子
完成了一份homework,以下代码包括R语言的基本数据运算,求对数,打印,设置函数。
> # Create a function with arguments.a stand P99 b stand P99.5 c stand P99.P99
> percentile_ratio_discrepancies <- function(a,b,c,d) {
+ pat0=log(a/c)
+ pata=1-log(10)/pat0
+ pat2=(a/c)^(1-pata)
+ pat3=(b/c)^(1-pata)
+ pat4=(a/b)^(1-pata)
+ sumAll=(pat2-10)^2+(pat3-5)^2+(pat4-2)^2
+ print(sumAll)
+ result= (sumAll)
+ }
>
> # Evaluate the function without supplying one of the arguments.
> percentile_ratio_discrepancies(a=1e6,b=2e6,c=1e7)
[1] 0
>
> # Create a function with arguments.a stand P99 b stand P99.5 c stand P99.P99
> exponent.multi_ratios_est <- function(a,b,c) {
+ pat0=log(a/c)
+ pata=1-log(10)/pat0
+ print(pata)
+ result= (pata)
+ }
>
> # Evaluate the function without supplying one of the arguments.
> taggetA<-exponent.multi_ratios_est(a=1e6,b=2e6,c=1e7)
[1] 2
> print(taggetA)