当前位置: 首页>>代码示例>>Python>>正文


Python Math.random方法代码示例

本文整理汇总了Python中java.lang.Math.random方法的典型用法代码示例。如果您正苦于以下问题:Python Math.random方法的具体用法?Python Math.random怎么用?Python Math.random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.Math的用法示例。


在下文中一共展示了Math.random方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: gemm

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import random [as 别名]
    def gemm(self, n):

        import time
        #from no.uib.cipr.matrix.nni import BLAS,LAPACK;
        from jarray import array, zeros
        from java.lang import Math, System
        import no.uib.cipr.matrix as matrix

        if n < 100:
            r = 100
        else:
            r = 10

        t = time.time()

        #A = zeros(n*n,'d')
        #B = zeros(n*n,'d')
        #C = zeros(n*n,'d')

        pin = range(n*n)

        #for i in pin:
        #    A[i] = Math.random();
        #    B[i] = Math.random();
        #    C[i] = Math.random();

        A = matrix.Matrices.random(n,n);
        B = matrix.Matrices.random(n,n);
        C = matrix.Matrices.random(n,n);


        alpha = Math.random()
        beta = Math.random()

        print "Random numbers time: "+str((time.time() - t))

        for i in range(10):
            #BLAS.gemm(BLAS.ColMajor, BLAS.NoTrans, BLAS.NoTrans, n, n, n, alpha, A, n, B, n, beta, C, n)
            A.multAdd(alpha,B, C)
            C.scale(beta);
            #E=D.mult(C, C.copy())

        t = time.time()

        for i in range(r):
            #BLAS.gemm(BLAS.ColMajor, BLAS.NoTrans, BLAS.NoTrans, n, n, n, alpha, A, n, B, n, beta, C, n)
            #D=A.mult(B, B.copy()); E=D.mult(C, C.copy());
            A.multAdd(alpha,B, C)
            C.scale(beta);

        s = (time.time() - t)
        print s
        f = 2 * (n + 1) * n * n
        mfs = (f / (s * 1000000.0)) * r

        print str(mfs)
开发者ID:gidiko,项目名称:gridapp,代码行数:58,代码来源:examples.py

示例2:

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import random [as 别名]
from org.csstudio.opibuilder.scriptUtil import PVUtil
from org.csstudio.opibuilder.scriptUtil import ColorFontUtil
from org.eclipse.jface.dialogs import MessageDialog
from java.lang import Math



if Math.random() > 0.5:
	color = ColorFontUtil.getColorFromRGB(0,160,0)
	colorName = "green"

else:
	color = ColorFontUtil.RED
	colorName = "red"

import WidgetUtil
WidgetUtil.setBackColor(display, "myIndicator", color)
WidgetUtil.setMyForeColor(widget, color)

MessageDialog.openInformation(
			None, "Dialog from Python Script", "Python says: my color is " + colorName);

开发者ID:ATNF,项目名称:cs-studio,代码行数:23,代码来源:ExecuteScriptFromAction.py

示例3: createValueList

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import random [as 别名]
def createValueList(d, d1, i):
  arraylist = ArrayList()
  for j in range(0, i):#Generate 20 values for each serie
    d2 = d + Math.random() * (d1 - d)
    arraylist.add(Double(d2))
  return arraylist
开发者ID:bpavie,项目名称:FijiJythonScripts,代码行数:8,代码来源:JFreeChartDemo_02_BoxAndWhisker.py


注:本文中的java.lang.Math.random方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。