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


Golang math.Log10函数代码示例

本文整理汇总了Golang中math.Log10函数的典型用法代码示例。如果您正苦于以下问题:Golang Log10函数的具体用法?Golang Log10怎么用?Golang Log10使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: main

func main() {
	if len(os.Args) != 2 {
		panic("You must give exactly one argument.")
	}
	outDir := os.Args[1]
	tempTable := table.NewOutTable(tempColNames...)
	yTable := table.NewOutTable(yColNames...)
	fGasTable := table.NewOutTable(fGasColNames...)

	minMassLog, maxMassLog := math.Log10(1e13), math.Log10(1e15)
	logWidth := (maxMassLog - minMassLog) / steps

	for massLog := minMassLog; massLog <= maxMassLog; massLog += logWidth {
		bMass := math.Pow(10, massLog)

		h := halo.New(fTh, ppt, cFunc, halo.Biased, bMass, z)

		bTemp := h.EWTemperature(halo.Biased, bpbt, ppt, h.R500cBias)
		cTemp := h.EWTemperature(halo.Corrected, cpbt, ppt, h.C500.R)
		tempTable.AddRow(bMass, h.C500.M, bTemp, cTemp, cTemp/bTemp)

		bY := h.ThompsonY(bpbt, ppt, h.R500cBias)
		cY := h.ThompsonY(cpbt, ppt, h.C500.R)
		yTable.AddRow(bMass, h.C500.M, bY, cY, cY/bY)

		bFGas := fGas(h, halo.Biased)
		cFGas := fGas(h, halo.Corrected)
		fGasTable.AddRow(bMass, h.C500.M, bFGas, cFGas, cFGas/bFGas)
	}

	tempTable.Write(table.KeepHeader, path.Join(outDir, "mass-temp.table"))
	yTable.Write(table.KeepHeader, path.Join(outDir, "mass-y.table"))
	fGasTable.Write(table.KeepHeader, path.Join(outDir, "mass-fgas.table"))
}
开发者ID:phil-mansfield,项目名称:halo,代码行数:34,代码来源:x-ray-scaling.go

示例2: test

func test(mod int, fn string) {
	input := []float64{}
	output := []float64{}
	for i := 0.1; i < 50; i = i + 0.05 {
		errCnt := 0
		for j := 0; j < 10; j++ {
			dc := hammingcode.NewDecoder(mod)
			in := genCode(i)
			dc.Accept(in)
			res := dc.ProcessMess()
			if chkErr([]int{0, 0, 0, 0, 0, 0, 0}, res) {
				errCnt += 1
			}
		}
		input = append(input, i)
		output = append(output, float64(errCnt+1)/(7*10))
	}

	f, err := os.Create(fn)

	if err != nil {
		panic(err)
	}
	defer f.Close()
	for i, _ := range input {
		fmt.Fprintf(f, "%f \t %f\n", math.Log10(input[i]), math.Log10(output[i]))
	}
}
开发者ID:postfix,项目名称:hammingcode,代码行数:28,代码来源:run.go

示例3: DBtoMIDI

func DBtoMIDI(db float64) uint8 {
	db = db - 6.0
	p := math.Pow(10.0, (db / 20.0))
	plog := math.Log10(p*14.5+1.0) / math.Log10(15.5)
	plog *= 127.0
	return uint8(round(plog))
}
开发者ID:JamesDunne,项目名称:eminor2,代码行数:7,代码来源:main.go

示例4: MMI

// MMI calculates the maximum Modificed Mercalli Intensity for the quake.
func (q *Quake) MMI() float64 {
	if q.err != nil {
		return -1. - 0
	}

	var w, m float64
	d := math.Abs(q.Depth)
	rupture := d

	if d < 100 {
		w = math.Min(0.5*math.Pow(10, q.Magnitude-5.39), 30.0)
		rupture = math.Max(d-0.5*w*0.85, 0.0)
	}

	if d < 70.0 {
		m = 4.40 + 1.26*q.Magnitude - 3.67*math.Log10(rupture*rupture*rupture+1634.691752)/3.0 + 0.012*d + 0.409
	} else {
		m = 3.76 + 1.48*q.Magnitude - 3.50*math.Log10(rupture*rupture*rupture)/3.0 + 0.0031*d
	}

	if m < 3.0 {
		m = -1.0
	}

	return m
}
开发者ID:GeoNet,项目名称:haz,代码行数:27,代码来源:quake.go

示例5: main

func main() {
	if len(os.Args) != 2 {
		panic("You must give exactly one argument.")
	}
	outDir := os.Args[1]
	outTable := table.NewOutTable(colNames...)

	fGas := func(h *halo.Halo, bt halo.BiasType, pbt halo.PressureBiasType) float64 {
		if bt != halo.Biased {
			return h.GasEnclosed(bt, pbt, valPpt, h.C500.R) /
				h.MassEnclosed(bt, h.C500.R)
		} else {
			return h.GasEnclosed(bt, pbt, valPpt, h.R500cBias) /
				h.MassEnclosed(bt, h.R500cBias)
		}
	}

	minMassLog, maxMassLog := math.Log10(1e13), math.Log10(1e15)
	logWidth := (maxMassLog - minMassLog) / steps

	for massLog := minMassLog; massLog <= maxMassLog; massLog += logWidth {
		mass := math.Pow(10, massLog)

		h := halo.New(fTh, simPpt, cFunc0, halo.Corrected, mass, 0.0)

		fGasCorrected := fGas(h, halo.Corrected, halo.EffectivePressure)
		fGasNaive := fGas(h, halo.Corrected, halo.NaiveThermalPressure)
		outTable.AddRow(mass, h.M500cBias, fGasCorrected, fGasNaive,
			fGasCorrected*mass, fGasNaive*h.M500cBias)
	}

	outTable.Write(table.KeepHeader, path.Join(outDir, "mass-fgas.table"))
}
开发者ID:phil-mansfield,项目名称:halo,代码行数:33,代码来源:mass-fgas.go

示例6: main

func main() {
	if len(os.Args) != 2 {
		panic("You must give exactly one argument.")
	}
	outDir := os.Args[1]
	outTable := table.NewOutTable(colNames...)

	minMassLog, maxMassLog := math.Log10(1e13), math.Log10(1e15)
	logWidth := (maxMassLog - minMassLog) / steps

	for massLog := minMassLog; massLog <= maxMassLog; massLog += logWidth {
		mass := math.Pow(10, massLog)
		
		h := halo.New(fTh, simPpt, cFunc0, halo.Corrected, mass, 0.0)

		mGas500Corrected := h.GasEnclosed(halo.Biased,
			halo.EffectivePressure, valPpt, h.C500.R)
		mGas500ThCorrected := h.GasEnclosed(halo.Biased,
			halo.EffectivePressure, valPpt, h.R500cBias)
		mGas500ThNaive := h.GasEnclosed(halo.Biased,
			halo.ThermalPressure, valPpt, h.R500cBias)

		outTable.AddRow(mass, h.M500cBias, mGas500Corrected,
			mGas500ThCorrected, mGas500ThNaive)
	}

	outTable.Write(table.KeepHeader, path.Join(outDir, "plot-type-comp.table"))
}
开发者ID:phil-mansfield,项目名称:halo,代码行数:28,代码来源:plot-type-comp.go

示例7: buildbodyword

func buildbodyword(candword string, fproba mfloat, tproba mmfloat, score float64, n int) (string, bool) {
	/* This function calls the word building sequence. */
	var ll byte
	if score < 0.0 {
		/* The word is not probable enough, let's abort */
		return "", false
	}
	if n == 0 {
		/* No more letters, let's check if the end transition is plausible */
		ll = candword[len(candword)-1]
		if score+10*math.Log10(fproba[ll]) > 0.0 {
			/* Yes, the candidate is plausible */
			return candword, true
		} else {
			/* Unfortunately, no */
			return "", false
		}
	}
	/* We are in the middle of the word */
	ll = candword[len(candword)-1]
	for l, p := range tproba[ll] {
		/* For each possible letter in the transition, let's try the transition until
		   we find something that works.
		*/
		nextcandword := candword + string(l)
		trycandword, worked := buildbodyword(nextcandword, fproba, tproba, score+10*math.Log10(p),
			n-1)
		if worked {
			/* This word works */
			return trycandword, true
		}
	}
	/* If we are here, no transition worked correctly. */
	return "", false
}
开发者ID:jfgobin,项目名称:Gostuff,代码行数:35,代码来源:markov-english.go

示例8: CountDigits

// CountDigits return number of digits in integer
func CountDigits(i int) int {
	if i < 0 {
		return int(math.Log10(math.Abs(float64(i)))) + 2
	}

	return int(math.Log10(float64(i))) + 1
}
开发者ID:essentialkaos,项目名称:ek,代码行数:8,代码来源:fmtutil.go

示例9: main

func main() {
	if len(os.Args) != 2 {
		panic("Must provite a target directory.")
	}

	outDir := os.Args[1]
	outTable := table.NewOutTable(colNames...)

	minMassLog, maxMassLog := math.Log10(1e13), math.Log10(1e15)
	logWidth := (maxMassLog - minMassLog) / steps

	for massLog := minMassLog; massLog <= maxMassLog; massLog += logWidth {
		mass := math.Pow(10, massLog)
		h := halo.New(fTh, simPpt, cFunc, halo.Biased, mass, 0.0)

		outTable.AddRow(mass,
			h.C500.M/h.M500cBias,
			1.0/h.FThermal(h.C500.R),
			1.0/h.FThermal(h.R500cBias),
			h.BFrac(h.C500.R),
			h.BFrac(h.R500cBias))
	}

	outTable.Write(table.KeepHeader, path.Join(outDir, "mass-false-bias.table"))
}
开发者ID:phil-mansfield,项目名称:halo,代码行数:25,代码来源:mass-false-bias.go

示例10: main

func main() {
	br := bufio.NewReader(os.Stdin)

	line, err := br.ReadString('\n')
	if err != nil {
		log.Fatal(err)
	}

	dna := strings.TrimSpace(line)

	line, err = br.ReadString('\n')
	if err != nil {
		log.Fatal(err)
	}

	for _, f := range strings.Fields(line) {
		gc, _ := strconv.ParseFloat(f, 64)
		lgc := math.Log10(gc / 2)
		lat := math.Log10((1 - gc) / 2)
		lp := float64(0)
		for i := 0; i < len(dna); i++ {
			switch dna[i] {
			case 'A', 'T':
				lp += lat
			case 'G', 'C':
				lp += lgc
			}
		}
		fmt.Print(lp, " ")
	}
	fmt.Println()
}
开发者ID:nkitchen,项目名称:rosalind,代码行数:32,代码来源:prob.go

示例11: main

func main() {
	if len(os.Args) != 2 {
		panic("Must provite a target directory.")
	}

	outDir := os.Args[1]
	outTable := table.NewOutTable(colNames...)

	minMassLog, maxMassLog := math.Log10(1e13), math.Log10(1e15)
	logWidth := (maxMassLog - minMassLog) / steps

	for massLog := minMassLog; massLog <= maxMassLog; massLog += logWidth {
		mass := math.Pow(10, massLog)

		h0 := halo.New(fTh, simPpt, cFunc0, halo.Biased, mass, 0.0)
		h0p := halo.New(fThP, simPpt, cFunc0, halo.Biased, mass, 0.0)
		h0m := halo.New(fThM, simPpt, cFunc0, halo.Biased, mass, 0.0)

		h2 := halo.New(fTh, simPpt, cFunc2, halo.Biased, mass, 0.2)
		h2p := halo.New(fThP, simPpt, cFunc2, halo.Biased, mass, 0.2)
		h2m := halo.New(fThM, simPpt, cFunc2, halo.Biased, mass, 0.2)

		outTable.AddRow(mass,
			h0.C500.M/h0.M500cBias,
			h0p.C500.M/h0p.M500cBias,
			h0m.C500.M/h0m.M500cBias,
			h2.C500.M/h2.M500cBias,
			h2p.C500.M/h2p.M500cBias,
			h2m.C500.M/h2m.M500cBias)
	}

	outTable.Write(table.KeepHeader, path.Join(outDir, "mass-bias.table"))
}
开发者ID:phil-mansfield,项目名称:halo,代码行数:33,代码来源:mass-bias.go

示例12: getMeans

// apply logarithmic transformation to amounts and number of transactions to normalize
// will more closely resemble a normal distribution so we can take z-scores
// aggregate a sum, then divide by total count to find means
// return as a struct of means
func getMeans(id mongoDBConfig.BrandId) (mean ZscoreData) {
	collections := mongoDBConfig.NewDBConn()
	visitorsCollection := collections.C("visitors")
	result := visitorsCollection.
		Find(bson.M{
			"brandid":       id,               // for which brand in our db are we computing z-scores
			"summaries.amt": bson.M{"$gt": 0}, // don't include $0 transactions
		}).
		Select(bson.M{
			"summaries.amt": 1,
			"summaries.trn": 1}).
		//Limit(100).
		Iter()

	visitor := Visitor{}
	count := 0
	// mgo next() will iterate through the dataset and unmarshal into vistor struct
	for result.Next(&visitor) {
		count += 1

		amt := visitor.Summaries.Amount
		amt = math.Log10(amt)
		mean.Amt += amt

		trn := float64(visitor.Summaries.NumberOfTransactions)
		trn = math.Log10(trn)
		mean.Trn += trn
	}

	mean.Amt = mean.Amt / float64(count)
	mean.Trn = mean.Trn / float64(count)
	return
}
开发者ID:tucobenedicto,项目名称:zscore,代码行数:37,代码来源:zscoreAPI.go

示例13: main

func main() {
	if len(os.Args) != 2 {
		panic("You must give exactly one argument.")
	}
	outDir := os.Args[1]
	outTable := table.NewOutTable(colNames...)

	minMassLog, maxMassLog := math.Log10(1e13), math.Log10(1e15)
	logWidth := (maxMassLog - minMassLog) / steps

	for massLog := minMassLog; massLog <= maxMassLog; massLog += logWidth {
		mass := math.Pow(10, massLog)

		h0 := halo.New(fTh, simPpt, cFunc0, halo.Biased, mass, 0.0)
		h0p := halo.New(fThP, simPpt, cFunc0, halo.Biased, mass, 0.0)
		h0m := halo.New(fThM, simPpt, cFunc0, halo.Biased, mass, 0.0)

		h5 := halo.New(fTh, simPpt, cFunc5, halo.Biased, mass, 0.5)
		h5p := halo.New(fThP, simPpt, cFunc5, halo.Biased, mass, 0.5)
		h5m := halo.New(fThM, simPpt, cFunc5, halo.Biased, mass, 0.5)

		outTable.AddRow(mass,
			h0.EWTemperature(tempBt, valPpt, h5p.C500.R),
			h0p.EWTemperature(tempBt, valPpt, h0p.C500.R),
			h0m.EWTemperature(tempBt, valPpt, h0m.C500.R),
			h5.EWTemperature(tempBt, valPpt, h5p.C500.R),
			h5p.EWTemperature(tempBt, valPpt, h5p.C500.R),
			h5m.EWTemperature(tempBt, valPpt, h5m.C500.R))
	}

	outTable.Write(table.KeepHeader, path.Join(outDir, "mass-temp.table"))
}
开发者ID:phil-mansfield,项目名称:halo,代码行数:32,代码来源:mass-temp.go

示例14: TranslatePixelCoordinate

/*
Translate pixel coordinates to actual coordinates
Needed: reference points for lower left conor and upper right conor
*/
func TranslatePixelCoordinate(linear bool, startEndValues []float64, startEndPixels []float64, pixelsIn []float64) (actualCoordinates []float64) {

	actualCoordinates = make([]float64, 0)
	transCoordinate := 0.0

	for _, pixelValue := range pixelsIn {

		if linear {

			transCoordinate = (pixelValue-startEndPixels[0])*(startEndValues[1]-startEndValues[0])/
				(startEndPixels[1]-startEndPixels[0]) + startEndValues[0]

		} else { //logrithmic

			//their powers are linear
			coordinateRatio := (pixelValue-startEndPixels[0])*(math.Log10(startEndValues[1])-math.Log10(startEndValues[0]))/
				(startEndPixels[1]-startEndPixels[0]) + math.Log10(startEndValues[0])

			transCoordinate = math.Pow(10, coordinateRatio)

		}

		actualCoordinates = append(actualCoordinates, transCoordinate)
	}

	return
}
开发者ID:posco,项目名称:xparser,代码行数:31,代码来源:xparser.go

示例15: compareImages

// if halfSize, m1 has to be 2*m2
func compareImages(m1, m2 image.Image, halfSize bool) results {
	b := m2.Bounds()
	s := b.Size()
	res := results{}
	mse := uint32(0)
	for y := b.Min.Y; y < b.Max.Y; y++ {
		for x := b.Min.X; x < b.Max.X; x++ {
			var r1, g1, b1, a1 uint32
			if halfSize {
				r1, g1, b1, a1 = m1.At(x*2, y*2).RGBA()
			} else {
				r1, g1, b1, a1 = m1.At(x, y).RGBA()
			}
			r2, g2, b2, a2 := m2.At(x, y).RGBA()
			mse += ((r1-r2)*(r1-r2) + (g1-g2)*(g1-g2) + (b1-b2)*(b1-b2)) / 3
			if r1 != r2 || g1 != g2 || b1 != b2 || a1 != a2 {
				if res.diffIm == nil {
					res.diffIm = image.NewGray(m1.Bounds())
				}
				res.diffCnt++
				res.diffIm.Set(x, y, color.White)
			}
		}
	}
	mse = mse / uint32(s.X*s.Y)
	res.psnr = 20*math.Log10(1<<16) - 10*math.Log10(float64(mse))
	return res
}
开发者ID:rfistman,项目名称:camlistore,代码行数:29,代码来源:resize_test.go


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