* * *

Recent Posts

Pages: [1] 2 3 ... 10
1
Beginners / Re: Deviation
« Last post by DieterV on Today at 02:35:01 pm »
Thanks for the reply RVK!

Sorry I tested it with 170 & 120 :D not 150  :-[

2
Beginners / Re: Deviation
« Last post by rvk on Today at 02:31:03 pm »
Try to put in some writelns to show the results in between the calculations.
(but I see you already did that)

If I fix the array problem I get 7,07 as deviation for 170 and 150.

But you say it should be 35,35?
Should the deviation of 170 and 150 be 14,14 ???
See http://www.calculator.net/standard-deviation-calculator.html?numberinputs=170%2C150&x=47&y=19

(my result is exactly half that so there is still something wrong in your calculations)
3
Beginners / Re: Deviation
« Last post by rvk on Today at 02:22:35 pm »
First problem when looking at your code.
You have SETLENGTH(arrHoogte,aantal);
Directly after you try to use arrHoogte[aantal] := waarde;

But you should know that a dynamic array is always 0-based !!
So when you so SetLength(arrHoogte, 1) you only get arrHoogte[0]
and if you do SetLength(arrHoogte, 2) you only get arrHoogte[0] and arrHoogte[1].

So you need to take that into account.
(Hint: You can put {$R+} at the top of your program. It will show you when you try to access something that you shouldn't)
4
Beginners / Re: Program flow
« Last post by RAW on Today at 02:19:25 pm »
Or like this... (Thaddy's idea .... saw it somewhere else...)

Code: Pascal  [Select]
  1. Procedure TForm1.FormClick(Sender: TObject);
  2.   Var
  3.    wnd: TForm;
  4.  Begin
  5.   wnd:= TForm.Create(Self);
  6.    Try
  7.     wnd.Caption  := 'MyNewWindow';
  8.     wnd.SetBounds(300, 300, 300, 300);
  9.     wnd.OnPaint  := @MyNewWindowOnPaint;
  10.     wnd.ShowModal;
  11.    Finally
  12.     wnd.Release;
  13.     wnd:= Nil;
  14.    End;
  15.  End;
  16.  
  17.  
  18. {$J+}
  19. Procedure TForm1.MyNewWindowOnPaint(Sender: TObject);
  20.   Const
  21.    booOnce: Boolean = False;
  22.  Begin
  23.   Inherited;
  24.  
  25.   If Not booOnce
  26.   Then
  27.    Begin
  28.     ShowMessage('After creating my new modal window...');
  29.     booOnce:= True;
  30.    End;
  31.  End;
  32. {$J-}
5
Beginners / Re: Deviation
« Last post by DieterV on Today at 02:18:36 pm »
Code: Pascal  [Select]
  1. for teller := 1 to aantal-1 do
  2.   begin
  3.     vergelijkGemiddelde:= SQR((arrHoogte[teller] - gemiddeldeHoogte));
  4.  
  5.   end;
  6.   writeln (vergelijkGemiddelde:0:2) ;                                                                                                                  


Hello, I get the value 21025,00 while It should be 1250.
Isnt this for count 1 SQR(170-145) so 25²
and for count 2 SQR(120-145) so -25²?

6
Linux / Re: Tstringlist Segfault
« Last post by liewald on Today at 02:13:04 pm »
OK I've sort of got it working.

All a bit strange!!!

because of the size of the data ( Multi-Terrabye Genetics, typical file 16-18GB text file) with wide strings I have typically loaded the strings as ansistrings and then added those to the stringlist. Up till now this has never been an issue (and on the file load and save) it still isn't. However in this routine for some reason trying to add, set or append an ansistring to the stringlist causes it to commit suicide! However if I use strings rather than ansistrings within the procedure it seems to work, even when it's multi-threaded. So my guess is it's probably something in the ansistring copy routine that's causing the segfault.

Dave
7
Beginners / Deviation
« Last post by DieterV on Today at 02:01:46 pm »
Hello all,

Once again I am stuck with my mind in a code.
It goes like this.
I am trying to teach myself. So I would love to get some explanation, not just copy paste code. So I can think about it.

I already checked this forum but didn't find any correct solution.

Code: Pascal  [Select]
  1. program afwijkingDieter;
  2.  
  3. // declare your variables here
  4.    var arrHoogte: array of real;
  5.   var aantal, teller, waarde:integer;
  6.   var totaalHoogte, gemiddeldeHoogte, deviatie, standaardDeviatie:real;
  7.   var vergelijkGemiddelde, totaalVanVergelijkteGemiddelde:real;
  8.   var aboveOnce,aboveTwice,tooShort:integer;
  9. begin
  10.  
  11.   aantal:=1;
  12.   totaalHoogte:=0;
  13.   SETLENGTH(arrHoogte,aantal);
  14.   repeat
  15.     writeln('Input hoogte of 0 om te stoppen.');
  16.     readln(waarde);
  17.     if (waarde <> 0) then
  18.     begin
  19.       arrHoogte[aantal] := waarde;
  20.       totaalHoogte:= totaalHoogte + arrHoogte[aantal];
  21.       aantal := aantal+1;
  22.       SETLENGTH(arrHoogte,aantal);
  23.     end;
  24.   until (waarde = 0);
  25.   gemiddeldeHoogte:= totaalHoogte/(aantal-1);
  26.   totaalVanVergelijkteGemiddelde:= 0;
  27.   for teller := 1 to aantal-1 do
  28.   begin
  29.     vergelijkGemiddelde:= SQR(arrHoogte[teller] - gemiddeldeHoogte);
  30.   end;
  31.   totaalVanVergelijkteGemiddelde:= totaalVanVergelijkteGemiddelde + vergelijkGemiddelde;
  32.   deviatie:= totaalVanVergelijkteGemiddelde / (aantal-1);
  33.   standaardDeviatie:= SQRT(deviatie);
  34.   aboveOnce:=0;
  35.   aboveTwice:= 0;
  36.   tooShort:=0;
  37.   for teller := 1 to aantal do
  38.   begin
  39.     if (arrHoogte[teller] > standaardDeviatie) then
  40.     begin
  41.       aboveOnce:= aboveOnce+1;
  42.       writeln(aboveOnce);
  43.     end;
  44.     if (aboveOnce > standaardDeviatie*2) then
  45.     begin
  46.       aboveTwice:= aboveTwice+1;
  47.     end;
  48.   end;
  49.   writeln();
  50.   writeln(('The average height is : '), gemiddeldeHoogte:0:2);
  51.   writeln(('The standard deviation is : '), standaardDeviatie:0:2);
  52.   writeln(('Amount of students one time above standard deviation are : '), aboveOnce);
  53.   writeln(('Amount of students two times above standard deviation are : '), aboveTwice);
  54.   writeln();
  55.   writeln(('Press enter to QUIT'));
  56.   readln();
  57. end.                              

When I use the 2 digits  170 and 150, the  deviation should be 35,35.

When I run this program i get 102.53.

I think the calculation is correct ....


Thanks for the feedback.
8
Beginners / Re: Program flow
« Last post by RAW on Today at 01:47:47 pm »
Or like this...

Code: Pascal  [Select]
  1. Procedure TForm1.FormClick(Sender: TObject);
  2.   Var
  3.    wnd: TForm;
  4.  Begin
  5.   wnd            := TForm.Create(Self);
  6.   wnd.Caption    := 'MyNewWindow';
  7.   wnd.SetBounds  (300, 300, 300, 300);
  8.   wnd.PopupMode  := pmExplicit;
  9.   wnd.PopupParent:= Self;
  10.   wnd.Show;
  11.  
  12.   ShowMessage('After creating my new window...');
  13.  End;
9
Android / Arduino meet LAMW:Android
« Last post by maxx on Today at 01:37:38 pm »
For Electronics Tinkerer - LAMW:BluetoothClient HC-05/06 + Arduino GPIO example

Firmware (look at Arduino app subfolder):
GPIO only auto/manual 3CH GPIO (LED/relay) controller
Builded for Sanguino(Atmega1284p-16Mhz) on Arduino 1.6.5 IDE
(possible rebuild as I think for Arduino Mega/Uno etc.. with slight code corrections)

Enjoy friends!  8-)
10
Beginners / Re: Program flow
« Last post by RAW on Today at 01:34:11 pm »
Quote
If I have some code I want run after the main form has been created ....
It depends on what you really want to achieve...  :)

This would be one way...
Code: Pascal  [Select]
  1. // PRIVATE
  2. //  booOnce: Boolean;
  3. Procedure TForm1.FormPaint(Sender: TObject);
  4.  Begin
  5.   If Not booOnce
  6.   Then
  7.    Begin
  8.     ShowMessage('OnPaint');
  9.     booOnce:= True;
  10.    End;
  11.  End;
Pages: [1] 2 3 ... 10

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus