定制 happyr/normal-distribution-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

happyr/normal-distribution-bundle

Composer 安装命令:

composer require happyr/normal-distribution-bundle

包简介

A bundle to calculate normal distribution and other related stuff

README 文档

README

Latest Version Software License SensioLabsInsight Total Downloads

A bundle to calculate distributions and some statistical important values with those distributions.

The API

This bundle has three services that helps you with your distribution. Each service and function has comments that describes how to use them and why. This is a brief overview.

Calculator

Use this service when you want to calculate a normal distribution. This service has two functions normalDistribution and standardDistribution. The later calculates the unit normal distribution where meanValue = 0 and the standardDistribution = 1.

The input to both functions is an array with values like array(3,6,2,6,4,2,3,6,8, ... );

DistributionManager

This service builds a distribution of any type and saves some data in the database. The public functions to this service are addDistribution, getPercentile and createValueFrequencyArray.

DistributionManager::addDistribution takes an identifier name and an array with the values and frequency as arguments. The array must be on the form ($value => $frequency). See example below.

<?php

namespace Acme\DemoBundle\Controller;

use Happyr\NormalDistributionBundle\Service\DistributionManager;

class DemoController
{
    public function testController()
    {
        $manager = $this->get(DistributionManager::class);

        $foo = array(8,6,2,6,4,2,3,6,4,8,2,7);
        $bar = $manager->createValueFrequencyArray($foo);
        /*
            $bar should now look like this:
            $bar = (
                2 => 3,
                3 => 1,
                4 => 2,
                6 => 3,
                7 => 1,
                8 => 2
            )
        */
        $summary = $manager->addDistribution('test_id', $bar);

        //get the percentile for a value
        $percentile = $manager->getPercentile('test_id', 3.5);

        $this->get('doctrine.orm.entity_manager')->flush();

        /* ... */
    }
}

StatisticsHelper

The StatisticsHelper is used when you want to get values from a pre-calcuated normal distribution.

  • getPercentile: Fetch the percentile for a given value
  • getZTransform: Perform a Z-transformation to get a normalized value given your normal distribution.
  • getStanine: Get the stanine value for a given value
  • getStanineForPercentile: Get the stanine value for a given percentile. This is useful when your distribution isn't a standard distribution.

Installation

Install it with Composer!

composer require happyr/normal-distribution-bundle

After the dependencies are downloaded, then register the bundle in the AppKernel.

<?php

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Happyr\NormalDistributionBundle\HappyrNormalDistributionBundle(),
    // ...
);

Update the database

The bundle contains two entities. You should update your database with a migration script or (if you are in a pure dev environment) run the following command:

php app:console doctrine:schema:update --force

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-01-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固