承接 outcloud/geometric-array-random 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

outcloud/geometric-array-random

Composer 安装命令:

composer require outcloud/geometric-array-random

包简介

This package can be used to get random value from an array with given probability for each value

README 文档

README

This package can be used to get values of given array with given geometric probability

Examples:

'Together' Input Mode

$matrix = [
    [1, 0.1], // value, probablility
    [2, 0.1],
    [3, 0.1],
    [4, 0.3],
    [5, 0.2],
    [null, 0.2],
]; 

$generator = new GeometricArrayRandom($matrix);
$result = $generator->nextNValues(10);  // possible result: [4, null, 5, 1, null, 5, 5, 4, null, 4]
$singleValue = $generator->nextValue(); // possible result : 4

'Separately' Input Mode

$matrix = [
    [1, 2, 3, 4, 5, null], // values
    [0.1, 0.1, 0.1, 0.3, 0.2, 0.2] // probabilities
]; 

$generator = new GeometricArrayRandom($matrix, GeometricArrayRandom::MODE_TWO_DIMENSIONS);
$result = $generator->nextNValues(10);  // possible result: [4, null, 5, 1, null, 5, 5, 4, null, 4]
$singleValue = $generator->nextValue(); // possible result : 4

Additional info

  • Sum of probabilities in single matrix must always be equal to 1.0 (Otherwise an exception will be thrown)
  • Probability is 'float' value greater or equal to 0 and lower or equal to 1 (Otherwise an exception will be thrown)
  • Each value must always have a probability assigned (Otherwise an exception will be thrown)

Installation:

composer require outcloud\geometric-array-random

I'm using Semantic Versioning http://semver.org/spec/v2.0.0.html

统计信息

  • 总下载量: 16.72k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-08-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固