Squares

General FreeBASIC programming questions.
fxm
Posts: 9980
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Squares

Postby fxm » Jul 06, 2020 5:35

coderJeff wrote:If you have no other question to ask, then just take the answers at face value that compression of random data is impossible.

Maybe he only knows how to write and not read!
angros47
Posts: 1729
Joined: Jun 21, 2005 19:04

Re: Squares

Postby angros47 » Jul 06, 2020 6:50

Sincerely, at this point I think he should be banned. He brings zero contribute to the forum, and he clearly hasn't learned anything from any answer he received from other users. We are running in circles, and it seems to go on since ten years!

At this point, either he is trolling (and then he would deserve a ban), or he must have some real behavioural issues (and then there is nothing we can do to help him)

Sorry for the vent, but I think this joke has lasted too long
coderJeff
Site Admin
Posts: 3342
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Squares

Postby coderJeff » Jul 06, 2020 8:01

albert wrote:..."The only way to compress data , is to look for patterns."
...You can't look for patterns in random data..

Albert, this is the answer. Believe it. Study maths to prove it. No more of this, thanks.
dodicat
Posts: 6718
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Squares

Postby dodicat » Jul 06, 2020 8:51

Albert has contributed to this forum in many ways, for a long time. For instance has made the fastest big number multiplier, he has made a parser, he has made games in opengl, he has extensively used win api and solved a few problems with his code with little help.
He never brags about his work.
He had a section for a while with trig art, which was well liked by many. He admits he is no great mathematician, so what.
There are a few supercilious specimens and bullies on this forum who deserve to be threatened a boot out, if only for the reason that they walk type amongst us.
If freebasic was a branch of the Institute of Mathematics, even then, I doubt if any of those stuffed shirts would advocate expulsion for somebody trying to prove a concept. in fact many of those that they ridiculed in the past came out tops in the end.
And remember our skier (British), Eddie the Eagle.
https://en.wikipedia.org/wiki/Eddie_the_Eagle
Ridiculed by all the alpine toffs. The same guy becomes a beacon for others, for his persistence and spirit if nothing else.
Albert reminds me of Eddie the Eagle, although he scores much higher at coding than Eddie did at skiing.
bfuller
Posts: 339
Joined: Jun 02, 2007 12:35
Location: Sydney, Australia

Re: Squares

Postby bfuller » Jul 06, 2020 11:29

Don't ban anyone or block this topic please. Even if the current infinite compression folly is pointless, Albert over the years has contributed in many ways and we should all try to gently suggest other topics or problems to solve---who knows, with such an obsessive mind, if he can be guided appropriately there may well be some brilliant solution to some particular programming problem just waiting to be discovered. No point in getting worked up.
fxm
Posts: 9980
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Squares

Postby fxm » Jul 06, 2020 15:25

bfuller wrote:Even if the current infinite compression folly is pointless

A current folly that started 10 years ago now.
(remember the "Circles" topic which was locked after one year)
angros47
Posts: 1729
Joined: Jun 21, 2005 19:04

Re: Squares

Postby angros47 » Jul 06, 2020 16:32

Indeed. This folly should be blocked, at this point. It's not good for anyone, especially for albert
albert
Posts: 5916
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Postby albert » Jul 21, 2020 22:42

@Dodicat

I've been playing around with "Altered Binary"

Where you use different numbers than the regular 1 , 2 , 4 , 8...
I've been fumbling around with Richards "Altered Binary" program he wrote for me...

But i need a better program...

Say if i start with a 3 , i need to find all the upper 7 bits and to adjust those bit positions , so the 8th bit is a small as possible..
If i start with a 3 , 4 , then ( 5 or 6 ) , i need a program to fill in the next upper bit positions...

Can you help??? I'd appreciate it...

=========================================================================================
!!~~ Back From The Ban~~!! .... It's funny that no one has posted to the "Squares" topic since i was banned...
The only people that post here to "Squares" are Dodicat , Richard and Albert.. and rarely sometimes another person..

I figured out another data compression , it's full-proof , but i won't post it...
But i want to share it with Dodicat.,
I told him if i get rich , I'd give him half the money , since I'm using his Zlib patch code for it...
All i can say is: If it's less than 8 bits then it makes it 8 bits , else if it equals 8 bits , then it makes it 7 or 6 bits.. so you can tell them apart...
=========================================================================================
Richard
Posts: 3035
Joined: Jan 15, 2007 20:44
Location: Australia

Re: Squares

Postby Richard » Jul 22, 2020 0:28

@albert
The 1, 2, 4, 8, … sequence gives a minimum length possible binary representation.
Any number can be encoded uniquely by adding a sub-set of values.

If instead you tried to use 1, 3, 4, 8, … then how could you encode 2 or 6 ?

If you try 1, 1, 3, 6, 12, 24, … it will take more bits to encode the same number than 1, 2, 4, 8, 16, …
There will also be two possible representations of some numbers, example 4, by using the first 1 or the second 1.
You will find numbers difficult to compare as many will have two different valid representations.

Having duplicate representations is inefficient, so you might as well stick to the compact 1, 2, 4, 8, ...
albert
Posts: 5916
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Postby albert » Jul 22, 2020 2:46

@Richard

Thanks for responding.. But i had directed the post to Dodicat..

Here's you "Altered Binary" code you wrote for me...

Code: Select all


screen 19

'====================================================
' put your choice of numbers in this array
Dim As Short non_binary( 0 To 7 ) = { 1, 4 , 6 , 8 , 16 , 32, 64, 128 }

'====================================================
Dim As Short k, sum, n = 0
For k As Short = 0 To 7
    n += non_binary( k )
Next k
Dim As Short freq( 0 To n )

'====================================================
' evaluate binary pattern for all 256 different bytes
For k = 0 To 255
    sum = 0
    If k And 1 Then sum += non_binary( 0 )
    If k And 2 Then sum += non_binary( 1 )
    If k And 4 Then sum += non_binary( 2 )
    If k And 8 Then sum += non_binary( 3 )
    If k And 16 Then sum += non_binary( 4 )
    If k And 32 Then sum += non_binary( 5 )
    If k And 64 Then sum += non_binary( 6 )
    If k And 128 Then sum += non_binary( 7 )
    freq( sum ) += 1    ' accumulate frequency distribution
Next k

'====================================================
' report if missing or duplicate
For k = 0 To n
    'If freq( k ) = 0 Then Print k; " is missing."
    If freq( k ) > 1 Then Print k; " is duplicated *"; freq( k )
Next k

Print " Maximum code is"; n
Print " Done. "

'====================================================
Sleep
'====================================================



The problem I'm having : is if you only enter 3 bits positions.. It outputs a bunch of equates...
You have to enter in all 8 bits ... Guessing ..

Could you alter it , so the equate part , only uses the entered bits... Instead of requiring all 8 bits to be set..
albert
Posts: 5916
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Postby albert » Jul 22, 2020 21:15

@Richard

I played with your code, and modified it to do 8 bits or less....

I've got to work on the ( "k and ? " ) so it can do any number of bits 1 to 64...

Code: Select all


screen 19

'====================================================
ReDim As Short a_b( 0 To 7 )
'Enter bit position values..
a_b( 0 ) = 10
a_b( 1 ) = 11
a_b( 2 ) = 12
a_b( 3 ) = 14
a_b( 4 ) = 15
a_b( 5 ) = 0
a_b( 6 ) = 0
a_b( 7 ) = 0

for a as ubyte = ubound( a_b ) to 0 step - 1
    if a_b( a ) > 0 then redim preserve a_b( a ) : exit for
next

'====================================================
Dim As Short k, sum, n = 0
For k As Short = 0 To ubound( a_b )
    n += a_b( k )
Next k
Dim As Short freq( 0 To n )

'====================================================
' evaluate binary pattern for all 256 different bytes
For k = 0 To ( 1 shl ( ubound( a_b) + 1 ) ) - 1
    sum = 0
    If k And 001 Then sum += a_b( 0 )
    If k And 002 Then sum += a_b( 1 )
    If k And 004 Then sum += a_b( 2 )
    If k And 008 Then sum += a_b( 3 )
    If k And 016 Then sum += a_b( 4 )
    If k And 032 Then sum += a_b( 5 )
    If k And 064 Then sum += a_b( 6 )
    If k And 128 Then sum += a_b( 7 )
    freq( sum ) += 1    ' accumulate frequency distribution
Next k

'====================================================
print "Bits = " ;
for a as ubyte = lbound( a_b) to ubound( a_b )
    print a_b( a ) ; "  " ;
next
print
print

' report if missing or duplicate
dim as longint  dups = 0
print "dups = " ;
For k = 0 To n
    'If freq( k ) = 0 Then Print k; " is missing."
    If freq( k ) > 1 Then dups+=1 : Print k ; "  " ; ' '" is duplicated *"; freq( k )
Next k

print
print
print "Total Duplicates = " ; dups

print
Print "Total Accumulated Bit Values = "; n
Print "Done. "

'====================================================
Sleep
'====================================================

albert
Posts: 5916
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Postby albert » Jul 22, 2020 22:13

It would be nice , if it could tell you what bit value might go next...

Or make it like an odometer
To go thru all possible values , and find the altered binary with the lowest output value...
Richard
Posts: 3035
Joined: Jan 15, 2007 20:44
Location: Australia

Re: Squares

Postby Richard » Jul 22, 2020 22:24

This handles less bits ...

Code: Select all

Screen 19

'====================================================
' put your choice of numbers in this array, 0 for unused MSBs
Dim As Short non_binary( 0 To 7 ) = { 1, 2 , 4 , 0 , 0 , 0, 0, 0 }

'====================================================
Dim As Short k, sum, n = 0, bits = 0
For k As Short = 0 To 7
    If non_binary( k ) Then
        n += non_binary( k )' find the maximum possible represented number
        bits += 1           ' find number of bits specified at LSB end
    Else
        Exit For       
    End If
Next k

Dim As Short freq( 0 To n )

'====================================================
' evaluate binary pattern for different possible codes
For k = 0 To 2^bits - 1
    sum = 0
    If k And   1 Then sum += non_binary( 0 )
    If k And   2 Then sum += non_binary( 1 )
    If k And   4 Then sum += non_binary( 2 )
    If k And   8 Then sum += non_binary( 3 )
    If k And  16 Then sum += non_binary( 4 )
    If k And  32 Then sum += non_binary( 5 )
    If k And  64 Then sum += non_binary( 6 )
    If k And 128 Then sum += non_binary( 7 )
    freq( sum ) += 1    ' accumulate frequency distribution
Next k

'====================================================
' report if missing or duplicate
For k = 0 To n
    'If freq( k ) = 0 Then Print k; " is missing."
    If freq( k ) > 1 Then Print k; " is duplicated *"; freq( k )
Next k

Print " Maximum code is"; n
Print " Done. "

'====================================================
Sleep
'====================================================
albert
Posts: 5916
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Postby albert » Jul 22, 2020 22:33

@Richard

For k = 0 To 2^bits - 1
sum = 0
If k And 1 Then sum += non_binary( 0 )
If k And 2 Then sum += non_binary( 1 )
If k And 4 Then sum += non_binary( 2 )
If k And 8 Then sum += non_binary( 3 )
If k And 16 Then sum += non_binary( 4 )
If k And 32 Then sum += non_binary( 5 )
If k And 64 Then sum += non_binary( 6 )
If k And 128 Then sum += non_binary( 7 )
freq( sum ) += 1 ' accumulate frequency distribution
Next k

How do you change the "If k and ? " , So it can do any number of bits , ( 1 to 64 )

Would you do a ( k shl ? )
Richard
Posts: 3035
Joined: Jan 15, 2007 20:44
Location: Australia

Re: Squares

Postby Richard » Jul 22, 2020 22:41

Keep it simple.
You can play with the least significant 4 bits and recognise the patterns.

Your computer will be replaced before you have time to test the frequency of all 2^64 possible states.

Return to “General”

Who is online

Users browsing this forum: No registered users and 2 guests