以awk计算对数

时间:2019-02-04 20:23:56

标签: awk

如何在awk中以10为底计算对数? 我尝试过

-2.5*log(10)($2)/log(10)

输出:83051.02180161216529给出了-5.7564,但是应该是-12.29836。谢谢。

2 个答案:

答案 0 :(得分:2)

以10为底的对数的正确公式为:

now.add(Calendar.MINUTE, diffInMin.toInt())

它给出了正确的答案:

    test: /(\.jsx|\.js)$/, // JSX and JS files should be present.
    exclude: /(node_modules|bower_components)/,
    use: [{
        loader: 'babel-loader',
        options: {
            // Babel must be required like this to be able to use npm-link to link to shared code, see:
            // https://stackoverflow.com/questions/34574403/how-to-set-resolve-for-babel-loader-presets/
            presets: [
                [node_modules + '/@babel/preset-env', {
                    // Ref: 1) http://2ality.com/2017/02/babel-preset-env.html
                    // 2) http://caniuse.com/usage-table
                    // In case it supports the browserlist in package.json, remove this here, see:
                    // https://github.com/babel/babel-preset-env/issues/149
                    "targets": {"browsers": ["> 4%", "safari 10", "ie 11", "iOS 9"]},
                    "modules": false,
                    "useBuiltIns": 'entry',
                    // "debug": true
                }],
                [node_modules + '/@babel/preset-react'],
            ],
            plugins: [
                node_modules + '/@babel/plugin-proposal-class-properties',
                node_modules + '/@babel/plugin-proposal-object-rest-spread'].map(require.resolve)
        }
    }]

答案 1 :(得分:1)

log用于底数e(自然对数)。只需将其更改为

$ awk 'BEGIN{print -2.5*log(83051)/log(10)}'

-12.2984

缩放比例将转换为以10为底。