小编Jos*_*osh的帖子

在R中绘制对数刻度

我试图绘制一个对数刻度,但我继续得到这个错误:

Error in plot.window(...) : invalid "log=1/h" specification. 
Run Code Online (Sandbox Code Playgroud)

我不确定我做错了什么.以下是我的代码:

   #function
function(stepsize, temp_val, counter) {
  while(counter < 0) {
    counter <- counter + stepsize
    px_norm <- dnorm(counter, mean = 0, sd = .04)
    temp_val <- temp_val + px_norm }
  temp_val <- 2*temp_val
  temp_val <- temp_val *(stepsize/2)
  print(temp_val, digits = 12)
}

#Initial step size
h <- .01 
while (h > .00001) {
  x <- calc_error(h, 0, -5) #Gives me a result around .5
  err <- x - (exp(-.02)*0.5)
  plot(1/h, err, log …
Run Code Online (Sandbox Code Playgroud)

statistics plot logarithm r graph

0
推荐指数
2
解决办法
4万
查看次数

R中的中位数需要数字数据

我试图计算给定向量的中位数,但是当我尝试时我不断收到错误:

median(returns)
Error in median.default(returns) : need numeric data

> returns
 [1] 0.001262733  -0.005048584 -0.009160197 0.010411955  -0.00542421 
 [6] -0.010982649 -0.005807832 0.000863131  -0.00210823  0.000117543 
[11] 0.001319904  0.005307534  0.005246006  0.008469327  0.006006664 
[16] -0.001411188 -0.011446652 0.002669714  0.003896259  -0.003060607
[21] 0.006306116  0.000895311  -0.006235211 -0.000856819 -0.00056599 
[26] 0.00808345   0.00038652   -0.004070623 0.008398158  -0.005976036
[31] 0.011270873  0.007959499  0.003776885  -0.000591663 0.001163452 
[36] 0.005759682  0.000678132  0.000609123  -0.000735042
40 Levels: -0.00056599 -0.000591663 -0.000735042 -0.000856819 ... 0.011270873

dput(returns)
structure(c(25L, 9L, 14L, 39L, 10L, 15L, 11L, 22L, 6L, 18L, 26L, 
31L, 30L, …
Run Code Online (Sandbox Code Playgroud)

statistics r vector median

0
推荐指数
1
解决办法
1万
查看次数

具有继承的构造函数定义

我的教授给出了以下代码来展示继承的一个例子:

//Base class
class Inventory {
    int quant, reorder; // #on-hand & reorder qty
    double price; // price of item
    char * descrip; // description of item
public:
    Inventory(int q, int r, double p, char *); // constructor
    ~Inventory(); // destructor
    void print();
    int get_quant() { return quant; }
    int get_reorder() { return reorder; }
    double get_price() { return price; }
};
Inventory::Inventory(int q, int r, double p, char * d) : quant (q), reorder (r), price (p)
{
    descrip …
Run Code Online (Sandbox Code Playgroud)

c++ constructor class object

0
推荐指数
1
解决办法
1097
查看次数

Python"不支持的操作数类型"

我正在用Python编写我的第一个程序,我收到一个错误:

 "TypeError: unsupported operand type (s) for /: 'str' and 'str'
Run Code Online (Sandbox Code Playgroud)

这就是我正在做的事情:

import sys
import math
import scipy.stats import norm

S_t = sys.argv[1];
K = sys.argv[2];
r = sys.argv[3];
T = sys.argv[4];
sigma_0 = sys.argv[5];

d1 = (math.log(S_t/K) + (r - pow(sigma_0, 2)/2)*T)/(simga_0*math.sqrt(T));
x = norm.cdf(d1);
Run Code Online (Sandbox Code Playgroud)

我不确定我的错误在哪里.另外,x = norm.cdf(d1)计算累积规范的最佳方法是什么?

python math python-3.x

0
推荐指数
1
解决办法
757
查看次数

如何删除R中矩阵中的NA

我有一个2020 X 4的矩阵.但是从2000行到2020年的值都是NA.我想删除这些行,我的矩阵现在应该是2000 X 4矩阵.有没有一种简单的方法可以做到这一点.

r matrix

-2
推荐指数
1
解决办法
1098
查看次数

标签 统计

r ×3

statistics ×2

c++ ×1

class ×1

constructor ×1

graph ×1

logarithm ×1

math ×1

matrix ×1

median ×1

object ×1

plot ×1

python ×1

python-3.x ×1

vector ×1