Click here to Skip to main content
15,914,071 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Modifying stringstream Pin
Jijo.Raj2-Nov-08 19:39
Jijo.Raj2-Nov-08 19:39 
NewsRe: Modifying stringstream Pin
CodingLover2-Nov-08 19:53
CodingLover2-Nov-08 19:53 
GeneralRe: Modifying stringstream Pin
Jijo.Raj2-Nov-08 20:03
Jijo.Raj2-Nov-08 20:03 
QuestionCreate New String Value in registry Pin
cpvc++2-Nov-08 18:23
cpvc++2-Nov-08 18:23 
AnswerRe: Create New String Value in registry Pin
Hamid_RT2-Nov-08 18:30
Hamid_RT2-Nov-08 18:30 
AnswerRe: Create New String Value in registry Pin
Jijo.Raj2-Nov-08 18:43
Jijo.Raj2-Nov-08 18:43 
Questionstandard deviation [modified] Pin
jonig192-Nov-08 18:20
jonig192-Nov-08 18:20 
AnswerRe: standard deviation Pin
enhzflep2-Nov-08 19:09
enhzflep2-Nov-08 19:09 
Dunno really. It's up to you - FindAverage seems like a perfectly suitable name.

Here's how I did it some time back:

//
// blenderOceanStdDev.c
//
// Implementation file for the complex number functions used by the blenderOcean module
//
// Contributors:  Simon Beeching - enhzflep
//         Date:  17 feb 2008

#include <math.h>    // for sqrt
#include <stdlib.h>  // for RAND_MAX

float calcArrayAvg(float *array, long numElements)
{
    double tmp = 0;
    long i;
      
    for (i=0; i<numElements; i++)
        tmp += array[i];
    tmp /= numElements;
    return tmp;
}

float calcStdDev(float *array, long numElements, float arrayAvg)
{
      double thisDev;
      double totalDev2 = 0.0;
      double varience;
      long i;
      
      for (i=0; i<numElements; i++)
      {
          thisDev = array[i] - arrayAvg;
          totalDev2 += thisDev*thisDev;
      }
      
      varience = totalDev2 / (float)numElements;
      return sqrt(varience);
}
      
void setArrayMean(float *array, long numElements, float newMean)
{
      double oldMean = calcArrayAvg(array, numElements);
      double delta = newMean - oldMean;
      long i;
      
      for (i=0; i<numElements; i++)
          array[i] += delta;
}

void setArrayStdDev(float *array, long numElements, float oldStdDev, float newStdDev)
{
     double scale;
     long i;
     
     scale = newStdDev / oldStdDev;
     for (i=0; i<numElements; i++)
         array[i] *= scale;
}

// creates an array of numElements floats
// this array is filled with random numbers before
// being adjusted so that the mean of the numbers in the array is 0.0
// and the standard deviation is 1.0
void standard_normal(float *array, long numElements)
{
     long i;
     double mean, stdDev;
     
     for (i=0; i<numElements; i++)
         array[i] = ((float)rand()/(float)RAND_MAX);
         
     mean = calcArrayAvg(array, numElements);
     stdDev = calcStdDev(array, numElements, mean);
     setArrayMean(array, numElements, 0.0);
     setArrayStdDev(array, numElements, stdDev, 1.0);
}

Simon.
GeneralRe: standard deviation Pin
jonig193-Nov-08 3:35
jonig193-Nov-08 3:35 
QuestionShow Bitmap image in CRichEdit Control Pin
Dhiraj kumar Saini2-Nov-08 18:05
Dhiraj kumar Saini2-Nov-08 18:05 
AnswerRe: Show Bitmap image in CRichEdit Control Pin
Hamid_RT2-Nov-08 18:19
Hamid_RT2-Nov-08 18:19 
AnswerRe: Show Bitmap image in CRichEdit Control Pin
enhzflep2-Nov-08 18:21
enhzflep2-Nov-08 18:21 
QuestioncapDriverConnect(hwnd_frame,0) Pin
anilaabc2-Nov-08 17:45
anilaabc2-Nov-08 17:45 
AnswerRe: capDriverConnect(hwnd_frame,0) Pin
Mark Salsbery3-Nov-08 5:42
Mark Salsbery3-Nov-08 5:42 
QuestionHelp for a dummy ! - How do add a Custom Control to my VC++6.0 MFC project. Pin
Neil Urquhart2-Nov-08 5:19
Neil Urquhart2-Nov-08 5:19 
AnswerRe: Help for a dummy ! - How do add a Custom Control to my VC++6.0 MFC project. Pin
Michael Dunn2-Nov-08 8:01
sitebuilderMichael Dunn2-Nov-08 8:01 
QuestionException Handling in Microsoft Visual C++ Express? Pin
Megidolaon2-Nov-08 2:31
Megidolaon2-Nov-08 2:31 
AnswerRe: Exception Handling in Microsoft Visual C++ Express? Pin
Michael Dunn2-Nov-08 8:06
sitebuilderMichael Dunn2-Nov-08 8:06 
GeneralRe: Exception Handling in Microsoft Visual C++ Express? Pin
Megidolaon2-Nov-08 23:00
Megidolaon2-Nov-08 23:00 
GeneralRe: Exception Handling in Microsoft Visual C++ Express? Pin
Michael Dunn3-Nov-08 19:44
sitebuilderMichael Dunn3-Nov-08 19:44 
GeneralRe: Exception Handling in Microsoft Visual C++ Express? Pin
Megidolaon4-Nov-08 6:36
Megidolaon4-Nov-08 6:36 
QuestionVisual Studio crashes Pin
Heptagonal1-Nov-08 23:01
Heptagonal1-Nov-08 23:01 
AnswerRe: Visual Studio crashes Pin
Michael Dunn2-Nov-08 8:08
sitebuilderMichael Dunn2-Nov-08 8:08 
Questionhow to delete icon of tool bar Pin
zhiyuan161-Nov-08 21:11
zhiyuan161-Nov-08 21:11 
AnswerRe: how to delete icon of tool bar Pin
Hamid_RT2-Nov-08 2:42
Hamid_RT2-Nov-08 2:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.