<commit_before>// Copyright 2022, University of Colorado Boulder

/**
 * QUnit tests for NumberProperty
 *
 * @author <NAME> (PhET Interactive Simulations)
 */

import dotRandom from '../../dot/js/dotRandom.js';
import VarianceNumberProperty from './VarianceNumberProperty.js';

QUnit.module( 'VarianceNumberProperty' );

QUnit.test( 'Test VarianceNumberProperty', assert => {

  const computeFunction = ( v: number ) => v + 1;

  const property = new VarianceNumberProperty( 0, computeFunction );

  assert.ok( property.getRandomizedValue() === 1, 'initial value' );
  // assert.ok( v.value === 1, 'value getter' );

  const mean = 6;
  const stardardDeviation = 2;
  const computeFunction2 = ( mean: number ): number => {
    let u = 0;
    let v = 0;
    while ( u === 0 ) {
      u = dotRandom.nextDouble();
    } //Converting [0,1) to (0,1)
    while ( v === 0 ) {
      v = dotRandom.nextDouble();
    }
    return (
      mean +
      stardardDeviation *
      Math.sqrt( -2.0 * Math.log( u ) ) *
      Math.cos( 2.0 * Math.PI * v )
    );
  };

  const property2 = new VarianceNumberProperty( mean, computeFunction2 );

  assert.ok( property2.getRandomizedValue() !== property2.getRandomizedValue(), 'randomly assigned' ); // eslint-disable-line no-self-compare

  // See the standard deviation in action!
  console.log( 'Variance number property tests:' );
  console.log( 'Mean: ' + mean );
  console.log( 'Standard deviation: ' + stardardDeviation );
  console.log( property2.getRandomizedValue() );
  console.log( property2.getRandomizedValue() );
  console.log( property2.getRandomizedValue() );
  console.log( property2.getRandomizedValue() );
  console.log( property2.getRandomizedValue() );
  console.log( property2.getRandomizedValue() );
  console.log( property2.getRandomizedValue() );
} );
<commit_msg>Add Property suffix to variables, see https://github.com/phetsims/chipper/issues/1335<commit_after>// Copyright 2022, University of Colorado Boulder

/**
 * QUnit tests for NumberProperty
 *
 * @author <NAME> (PhET Interactive Simulations)
 */

import dotRandom from '../../dot/js/dotRandom.js';
import VarianceNumberProperty from './VarianceNumberProperty.js';

QUnit.module( 'VarianceNumberProperty' );

QUnit.test( 'Test VarianceNumberProperty', assert => {

  const computeFunction = ( v: number ) => v + 1;

  const property = new VarianceNumberProperty( 0, computeFunction );

  assert.ok( property.getRandomizedValue() === 1, 'initial value' );
  // assert.ok( v.value === 1, 'value getter' );

  const mean = 6;
  const stardardDeviation = 2;
  const computeFunction2 = ( mean: number ): number => {
    let u = 0;
    let v = 0;
    while ( u === 0 ) {
      u = dotRandom.nextDouble();
    } //Converting [0,1) to (0,1)
    while ( v === 0 ) {
      v = dotRandom.nextDouble();
    }
    return (
      mean +
      stardardDeviation *
      Math.sqrt( -2.0 * Math.log( u ) ) *
      Math.cos( 2.0 * Math.PI * v )
    );
  };

  const secondProperty = new VarianceNumberProperty( mean, computeFunction2 );

  assert.ok( secondProperty.getRandomizedValue() !== secondProperty.getRandomizedValue(), 'randomly assigned' ); // eslint-disable-line no-self-compare

  // See the standard deviation in action!
  console.log( 'Variance number property tests:' );
  console.log( 'Mean: ' + mean );
  console.log( 'Standard deviation: ' + stardardDeviation );
  console.log( secondProperty.getRandomizedValue() );
  console.log( secondProperty.getRandomizedValue() );
  console.log( secondProperty.getRandomizedValue() );
  console.log( secondProperty.getRandomizedValue() );
  console.log( secondProperty.getRandomizedValue() );
  console.log( secondProperty.getRandomizedValue() );
  console.log( secondProperty.getRandomizedValue() );
} );

{'fraction_non_alphanumeric': 0.14426142401700318, 'fraction_numerical': 0.01647183846971307, 'mean_word_length': 3.6026894865525674, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '106358', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1157, 'n_words': 284}